﻿*----------------------------------------------------------------------------------------------------------	* 
* RESEARCHERS:		EARN												   						   			*
* PROGRAMMED BY:	Linea Hasager																   			*
* DESCRIPTION:		Creates predetermined covariates for balancing tests, and outcome variables.			*
*					1) Set directories and macros															*
*					2) Load inputdata																		*
*					3) Generate new variables																*
*					4) Export data to Stata																	*
* CREATED:			Mar. 8, 2018																		   	*
* LAST MODIFIED:	May 31, 2022													       					*
* Note:				Run program with SAS Enterprise Guide 7.1
*----------------------------------------------------------------------------------------------------------	;


*-----------------------------------------------------------------------------------------------------------;
*	1) DIRECTORIES AND MACROS;
*-----------------------------------------------------------------------------------------------------------;

*DIRECTORIES;
libname pop 	"H:\Rawdata\707455\Grunddata";
libname raw 	"H:\Rawdata\707455\Views";
libname in 		"L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input";
libname crossw 	"L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input";
libname us 		"H:\rawdata\707455\Eksterne data\US";

%let input		=	L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input;
%let dkdb		=	L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input;


*-----------------------------------------------------------------------------------------------------------;


*DOLLAR-DKK EXCHANGE RATE TO CONVERT TO USD (FROM MARCH 27TH 2019);
*AND RESCALE TO 1000 DOLLARS;
%let dollar		=	6.6;
%let thousand	=	1000;


*DEFINE CRIMES (SHOPLIFTING);
%let property_sm			=	1332515;


*MACROS FOR TRAINING PROGRAMS IN AMFORA;
%let language=('128','129');
%let soc=('127');

*DEFINE FORMAL EDUCATION IN DENMARK (HF_KILDE FROM UDDA);
%let educ_dk=(1, 13, 15, 4, 6);


*FORMATS FOR EDUCATION LEVELS;
Proc Format;
value UDD_HOVED_L1L5_K
0='90'                     
1='10'                     
1006='10'                     
1007='10'                     
1008='10'                     
1009='10'                     
1010='10'                     
1011='10'                     
1021='10'                     
1022='10'                     
1023='10'                     
1031='20'                     
1032='20'                     
1040='20'                     
1041='20'                     
1042='20'                     
1049='20'                     
1051='20'                     
1052='20'                     
1061='20'                     
1062='20'                     
1064='20'                     
1069='20'                     
1070='20'                     
1071='20'                     
1072='20'                     
1073='20'                     
1080='20'                     
1081='20'                     
1082='20'                     
1083='20'                     
1084='20'                     
1090='90'                     
1095='90'                     
1097='20'                     
1098='20'                     
1099='90'                     
1100='10'                     
1101='10'                     
1102='10'                     
1103='10'                     
1104='10'                     
1105='10'                     
1106='10'                     
1107='10'                     
1108='10'                     
1109='10'                     
1110='10'                     
1111='10' 
1114='10' 
1115='10' 
1116='10'  
1117='10'   
1120='10'                     
1121='10'                     
1122='10'                     
1123='10'                     
1140='20'                     
1141='20'                     
1142='20'                     
1143='20'                     
1144='20'                     
1145='20'                     
1146='20'                     
1149='20'                     
1151='20'                     
1152='20'                     
1153='20'                     
1154='20'                     
1155='20'                     
1161='20'                     
1162='20'                     
1163='20'                     
1164='20'                     
1165='20'                     
1169='20'                     
1171='20'                     
1172='20'                     
1173='20'                     
1174='20'                     
1175='20'                     
1179='20'                     
1181='20'                     
1182='20'                     
1183='20'                     
1184='20'                     
1185='20'                     
1189='20'                     
1190='35'                     
1195='35'                     
1196='20'                     
1197='20'                     
1198='20'                     
1199='20'                     
1206='10'                     
1207='10'                     
1208='10'                     
1209='10'                     
1210='10'                     
1301='25'                     
1302='25'                     
1303='25'                     
1304='25'                     
1305='25'                     
1351='15'                     
1352='15'                     
1353='15'                     
1354='15'                     
1355='15'                     
1356='15'                     
1357='15'                     
1359='15'                     
1365='15'                     
141='40'                     
1410='10'                     
1423='10'                     
144='40'                     
145='40'                     
146='40'                     
148='40'                     
150='50'                     
1509='10'                     
151='50'                     
1510='10'                     
152='50'                     
1522='10'                     
1523='10'                     
153='50'                     
1531='20'                     
1532='20'                     
1533='20'                     
1535='20'                     
1536='20'                     
1537='20'                     
1539='20'                     
154='50'                     
1540='20'                     
1541='20'                     
1542='20'                     
1543='20'                     
1549='20'                     
155='50'                     
1551='20'                     
1552='20'                     
1553='20'                     
1555='20'                     
1559='20'                     
156='50'                     
1561='20'                     
1562='20'                     
1563='20'                     
1565='20'                     
1569='20'                     
159='50'                     
161='60'                     
162='60'                     
163='60'                     
164='60'                     
165='60'                     
1650='20'                     
1651='20'                     
1652='20'                     
167='60'                     
1671='20'                     
1672='20'                     
1673='20'                     
1679='20'                     
1681='20'                     
1682='20'                     
1683='20'                     
1689='20'                     
170='70'                     
171='70'                     
172='70'                     
1721='10'                     
1722='10'                     
1723='10'                     
173='70'                     
174='70'                     
175='70'                     
176='70'                     
177='70'                     
179='70'                     
1879='20'                     
1889='20'                     
1891='20'                     
1892='20'                     
1893='20'
1894='20' 
1895='20' 
1896='20'                     
1897='20'                     
1898='20'                     
1899='20'                     
1901='15'                     
1984='05'                     
1985='05'                     
2='90'                     
200='10'                     
2003='30' 
2004='30' 
2005='30'                     
2007='30'                     
2008='30'                     
2009='30'                     
2010='30'
2013='30' 
2015='30'                     
2016='30'                     
2017='30'                     
2018='30'                     
2021='30'                     
2022='30'                     
2027='30'                     
2028='30'                     
2029='50'                     
205='10'                     
210='10'                     
215='20'                     
220='39'                     
239='39'                     
2401='10'                     
2411='15'                     
2413='15'                     
2414='40'                     
2415='15'                     
2417='15'                     
2419='30'                     
2421='15'                     
2425='15'                     
2428='15'                     
2431='15'                     
2432='15'                     
2441='15'                     
2442='15'                     
2443='15'                     
2444='15'                     
2445='15'                     
2446='15'                     
2447='15'                     
2459='30'                     
2460='30'                     
2461='30'                     
2462='30'                     
2463='40'                     
2464='40'                     
2465='40'                     
2466='40'                     
2467='40'                     
2468='40'                     
2469='30'                     
2470='30'                     
2471='30'                     
2472='15'                     
2473='30'                     
2475='40'                     
2476='30'                     
2477='30'                     
2478='30'                     
2479='30'                     
2480='30'                     
2481='30'                     
2483='30'                     
2484='30'                     
2485='30'                     
2486='30'                     
2487='30'                     
2488='30'                     
2489='30'                     
2490='30'                     
2491='30'                     
2492='15'                     
2493='30'                     
2494='30'                     
2495='30'                     
2508='10'                     
2509='10'                     
2510='10'                     
2511='10' 
2515='10' 
2516='10'
2517='10'  
253='39'                     
2530='15'                     
254='39'                     
255='39'                     
258='39'                     
260='39'                     
275='39'                     
280='39'                     
285='39'                     
290='39'                     
2900='39'                     
2901='39'                     
2902='39'                     
2903='39'                     
2904='39'                     
2905='39'                     
2906='39'                     
2907='39'                     
2908='39'                     
2909='39'                     
2910='39'                     
2911='39'                     
2912='39'                     
2913='39'                     
2914='39'                     
2915='39'                     
2916='39'                     
2917='39'                     
2918='39'                     
2919='39'                     
2920='39'                     
2921='39'                     
2922='39'                     
2923='39'                     
2924='39'                     
2925='39'                     
2926='39'                     
2950='39'                     
2951='39'                     
2952='39'                     
2953='39'                     
2954='39'                     
2955='39'                     
2956='39'                     
2957='39'                     
2958='39'                     
2959='39'                     
2960='39'                     
2961='39'                     
2969='39'                     
2970='39'                     
2971='39'                     
2972='39'                     
2973='39'                     
2974='39'                     
2975='39'                     
2976='39'                     
2977='39'                     
2978='39'                     
2979='39'                     
2980='39'                     
2981='39'                     
2982='39'                     
2983='39'                     
2984='39'                     
2985='39'                     
2986='39'                     
2990='39'                     
2991='39'                     
2992='39'                     
300='30'                     
3000='70'                     
3001='70'                     
3002='70'                     
3003='70'                     
3004='70'                     
3005='70'                     
3006='60'                     
3007='60'                     
3008='60'                     
3009='60'                     
3010='60'                     
3011='60'                     
3012='60'                     
3013='60'                     
3014='60'                     
3015='60'                     
3016='60'                     
3017='60'                     
3018='60'                     
3019='60'                     
3020='70'                     
3021='70'                     
3022='60'                     
3023='60'                     
3024='70'                     
3025='60'                     
3026='60'                     
3027='60'                     
3028='70'                     
3029='70'                     
3030='70'                     
3031='70'                     
3032='60'                     
3033='70'                     
3034='60'                     
3035='70'                     
3036='60'                     
3037='60'                     
3038='60'                     
3039='60'                     
3040='70'                     
3041='60'                     
3042='70'                     
3043='60'                     
3044='39'                     
3045='60'                     
3046='70'                     
3047='70'                     
3048='70'                     
3049='70'                     
3050='70'                     
3051='70'                     
3052='70'                     
3053='60'                     
3054='70'                     
3055='60'                     
3056='60'                     
3057='70'                     
3058='70'                     
3059='70'                     
3060='70'                     
3061='70'                     
3062='60'                     
3063='70'                     
3064='60'                     
3065='60'                     
3066='60'                     
3067='70'                     
3068='60'                     
3069='70'                     
3070='70'                     
3071='60'                     
3072='60'                     
3073='60'                     
3074='60'                     
3075='70'                     
3076='70'                     
3077='70'                     
3078='70'                     
3079='70'                     
3080='60'                     
3081='70'                     
3082='70'                     
3083='60'                     
3084='60'                     
3085='70'                     
3086='70'                     
3087='60'                     
3088='60'                     
3089='60'                     
3090='60'                     
3091='70'                     
3092='70'                     
3093='70'                     
3094='60'                     
3095='70'                     
3096='70'                     
3097='60'                     
3098='70'                     
3099='70'                     
3100='60'                     
3101='70'                     
3102='70'                     
3103='70'                     
3104='70'                     
3105='60'                     
3106='70'                     
3107='70'                     
3108='70'                     
3109='70'                     
3110='70'                     
3111='70'                     
3112='70'                     
3113='70'                     
3114='70'                     
3115='70'                     
3116='60'                     
3117='70'                     
3118='70'                     
3119='70'                     
3120='70'                     
3121='60'                     
3122='60'                     
3123='70'                     
3124='60'                     
3125='70'                     
3126='70'                     
3127='70'                     
3128='70'                     
3129='70'                     
3130='70'                     
3131='70'                     
3132='70'                     
3133='70'                     
3134='70'                     
3135='39'                     
3136='70'                     
3137='70'                     
3138='70'                     
3139='70'                     
3140='70'                     
3141='70'                     
3142='70'                     
3143='70'                     
3144='70'                     
3145='70'                     
3146='70'                     
3147='70'                     
3148='60'                     
3149='70'                     
3150='70'                     
3151='70'                     
3152='70'                     
3153='70'                     
3154='60'                     
3155='70'                     
3156='70'                     
3157='70'                     
3158='70'                     
3159='39'                     
3160='70'                     
3161='70'                     
3162='60'                     
3163='70'                     
3164='70'                     
3165='70'                     
3166='60'                     
3167='70'                     
3171='60'                     
3172='60'                     
3173='70'                     
3174='70'                     
3176='70'                     
3177='60'                     
3178='50'                     
3179='50'                     
3180='50'                     
3181='39'                     
3182='50'                     
3183='50'                     
3184='50'                     
3185='50'                     
3186='50'                     
3187='50'                     
3188='50'                     
3189='50'                     
3190='50'                     
3191='50'                     
3192='50'                     
3193='50'                     
3194='50'                     
3195='50'                     
3196='50'                     
3197='50'                     
3198='50'                     
3199='50'                     
320='30'                     
3200='50'                     
3201='50'                     
3202='50'                     
3203='50'                     
3204='50'                     
3205='50'                     
3206='50'                     
3207='70'                     
3208='40'                     
3209='50'                     
3210='40'                     
3211='60'                     
3212='60'                     
3213='70'                     
3214='70'                     
3215='70'                     
3216='70'                     
3217='60'                     
3219='60'                     
3220='60'                     
3221='60'                     
3222='70'                     
3223='50'                     
3224='70'                     
3225='30'                     
3226='30'                     
3227='30'                     
3228='30'                     
3229='30'                     
3230='50'                     
3231='29'                     
3232='29'                     
3233='29'                     
3234='29'                     
3235='30'                     
3236='30'                     
3237='30'                     
3238='30'                     
3239='30'                     
3240='30'                     
3241='30'                     
3242='30'                     
3243='30'                     
3244='30'                     
3245='30'                     
3246='30'                     
3247='30'                     
3248='30'                     
3249='30'                     
3250='30'                     
3251='30'                     
3252='30'                     
3253='30'                     
3254='30'                     
3255='30'                     
3256='30'                     
3257='30'                     
3258='30'                     
3259='30'                     
3260='30'                     
3261='50'                     
3262='30'                     
3263='30'                     
3264='30'                     
3265='30'                     
3266='30'                     
3267='30'                     
3268='30'                     
3269='30'                     
3270='30'                     
3271='30'                     
3274='50'                     
3275='30'                     
3276='50'                     
3277='50'                     
3278='50'                     
3279='50'                     
3280='50'                     
3281='39'                     
3282='50'                     
3283='50'                     
3284='50'                     
3285='39'                     
3286='50'                     
3287='39'                     
3288='50'                     
3289='50'                     
3290='50'                     
3291='39'                     
3292='30'                     
3293='30'                     
3294='30'                     
3295='30'                     
3296='30'                     
3297='30'                     
3298='30'                     
3299='30'                     
3300='30'                     
3301='30'                     
3302='30'                     
3303='30'                     
3304='60'                     
3305='40'                     
3306='40'                     
3307='70'                     
3308='70'                     
3309='70'                     
3310='70'                     
3311='70'                     
3312='70'                     
3313='70'                     
3314='70'                     
3315='70'                     
3316='50'                     
3317='70'                     
3318='70'                     
3319='25'                     
3320='40'                     
3321='50'                     
3322='50'                     
3323='20'                     
3324='20'                     
3325='30'                     
3326='70'                     
3327='60'                     
3329='50'                     
3330='70'                     
3331='70'                     
3332='70'                     
3333='50'                     
3334='70'                     
3335='60'                     
3336='70'                     
3337='70' 
3338='70'  
3339='60'                     
3340='70'                     
3341='70'                     
3342='60'                     
3343='60'                     
3344='70'                     
3345='70'                     
3346='60'                     
3347='70'                     
3348='70'                     
3349='70'                     
3350='40'                     
3351='40'                     
3352='40'                     
3353='60'                     
3354='70'                     
3355='50'                     
3356='60'                     
3357='50'                     
339='30'                     
353='30'                     
3535='70'                     
354='30'                     
355='30'                     
358='30'                     
3597='30'                     
3598='30'                     
3599='39'                     
360='30'                     
3600='39'                     
3601='39'                     
3602='39'                     
3603='39'                     
3604='39'                     
3605='39'                     
3606='39'                     
3607='39'                     
3608='39'                     
3609='39'                     
3610='39'                     
3611='39'                     
3612='39'                     
3613='39'                     
3614='39'                     
3615='39'                     
3616='39'                     
3617='39'                     
3618='39'                     
3619='39'                     
3620='39'                     
3621='39'                     
3622='39'                     
3623='39'                     
3624='39'                     
3625='39'                     
3626='39'                     
3627='39'                     
3628='39'                     
3629='39'                     
3630='39'                     
3631='39'                     
3632='39'                     
3633='39'                     
3634='39'                     
3635='39'                     
3636='39'                     
3637='39'                     
3638='39'                     
3639='39'                     
3640='39'                     
3641='39'                     
3642='39'                     
3643='39'                     
3644='39'                     
3645='39'                     
3646='39'                     
3647='39'                     
3648='39'                     
3649='39'                     
3650='39'                     
3651='39'                     
3652='39'                     
3653='39'                     
3654='39'                     
3655='39'                     
3656='39'                     
3657='39'                     
3658='39'                     
3659='39'                     
3660='39'                     
3661='39'                     
3662='39'                     
3663='39'                     
3664='39'                     
3665='39'                     
3666='39'                     
3667='39'                     
3668='39'                     
3669='39'                     
3670='39'                     
3671='39'                     
3672='39'                     
3673='39'                     
3674='39'                     
3675='39'                     
3676='39'                     
3677='39'                     
3678='39'                     
3679='39'                     
3680='39'                     
3681='39'                     
3682='39'                     
3683='39'                     
3684='39'                     
3685='39'                     
3686='39'                     
3687='39'                     
3688='39'                     
3689='39'                     
3690='39'                     
3691='39'                     
3692='39'                     
3693='39'                     
3694='39'                     
3695='39'                     
3696='39'                     
3697='39'                     
3698='39'                     
3699='39'                     
3700='39'                     
3701='39'                     
3702='39'                     
3703='39'                     
3704='39'                     
3705='39'                     
3706='39'                     
3707='39'                     
3708='39'                     
3709='39'                     
3710='39'                     
3711='39'                     
3712='39'                     
3713='39'                     
3714='39'                     
3715='39'                     
3716='39'                     
3717='39'                     
3718='39'                     
3719='39'                     
3720='39'                     
3721='39'                     
3722='39'                     
3723='39'                     
3724='39'                     
3725='39'                     
3726='39'                     
3727='39'                     
3728='39'                     
3729='39'                     
3730='39'                     
3731='39'                     
3732='39'                     
3733='39'                     
3734='39'                     
3735='39'                     
3736='39'                     
3737='39'                     
3738='39'                     
3739='39'                     
3740='39'                     
3741='39'                     
3742='39'                     
3743='39'                     
3744='40'                     
3745='40'                     
3746='40'                     
3747='40'                     
3748='40'                     
3749='39'                     
375='30'                     
3750='40'                     
3751='39'                     
3752='40'                     
3753='39'                     
3754='39'                     
3755='50'                     
3756='39'                     
3757='39'                     
3758='39'                     
3759='39'                     
3760='40'                     
3761='39'                     
3762='39'                     
3763='39'                     
3764='39'                     
3765='40'                     
3766='39'                     
3767='39'                     
3768='39'                     
3769='39'                     
3770='50'                     
3771='39'                     
3772='39'                     
3773='39'                     
3774='39'                     
3775='40'                     
3776='39'                     
3777='39'                     
3778='39'                     
3779='39'                     
3780='30'                     
3781='39'                     
3782='39'                     
3783='39'                     
3784='39'                     
3785='30'                     
3786='39'                     
3787='39'                     
3788='39'                     
3789='39'                     
3790='30'                     
3791='39'                     
3792='39'                     
3793='39'                     
3794='39'                     
3795='39'                     
3796='39'                     
3797='39'                     
3798='39'                     
3799='39'                     
380='30'                     
3800='40'                     
3801='40'                     
3802='40'                     
3803='40'                     
3804='40'                     
3805='39'                     
3806='40'                     
3807='40'                     
3808='39'                     
3809='40'                     
3810='70'                     
3811='40'                     
3812='40'                     
3813='40'                     
3814='40'                     
3815='40'                     
3816='40'                     
3817='40'                     
3818='40'                     
3819='40'                     
3820='40'                     
3821='40'                     
3822='40'                     
3823='40'                     
3824='40'                     
3825='40'                     
3826='40'                     
3827='40'                     
3828='40'                     
3829='40'                     
3830='40'                     
3831='40'                     
3832='40'                     
3833='40'                     
3834='40'                     
3835='30'                     
3836='40'                     
3837='40'                     
3838='40'                     
3839='40'                     
3840='40'                     
3841='40'                     
3842='40'                     
3843='40'                     
3844='40'                     
3845='40'                     
3846='40'                     
3847='40'                     
3848='40'                     
3849='40'                     
385='30'                     
3850='40'                     
3851='40'                     
3852='40'                     
3853='40'                     
3854='40'                     
3855='40'                     
3856='40'                     
3857='40'                     
3858='40'                     
3859='40'                     
3860='40'                     
3861='40'                     
3862='40'                     
3863='40'                     
3864='40'                     
3865='40'                     
3866='40'                     
3867='40'                     
3868='39'                     
3869='39'                     
3870='30'                     
3871='39'                     
3872='40'                     
3873='39'                     
3875='40'                     
3880='30'                     
3885='30'                     
390='30'                     
3910='30'                     
3915='30'                     
3920='30'                     
3925='30'                     
3930='30'                     
3935='30'                     
3939='30'                     
3940='30'                     
3941='30'                     
3942='15'                     
3943='50'                     
3945='40'                     
3950='40'                     
3955='15'                     
3960='30'                     
3961='30'                     
3965='30'                     
3970='40'                     
3971='40'                     
3972='40'                     
400='40'                     
4000='40'                     
4001='29'                     
4002='29'                     
4003='29'                     
4004='29'                     
4005='40'                     
4006='40'                     
4007='40'                     
4008='20'                     
4009='40'                     
4010='30'                     
4011='40'                     
4012='40'                     
4013='40'                     
4014='40'                     
4015='40'                     
4017='40'                     
4018='40'                     
4019='40'                     
4020='40'                     
4021='40'                     
4022='40'                     
4023='40'                     
4024='40'                     
4025='40'                     
4026='40'                     
4027='40'                     
4028='40'                     
4029='40'                     
4030='40'
4031='20' 
4032='60'                     
4033='60'                     
4034='60'                     
4035='60'                     
4036='40'                     
4037='40'                     
4038='30'                     
4039='30'                     
4040='50'                     
4041='50'                     
4044='30'                     
4045='30'                     
4048='60'                     
4049='40'                     
4050='40'                     
4051='39'                     
4052='40'                     
4053='30'                     
4054='40'                     
4055='50'                     
4056='35'                     
4057='35'                     
4058='35'                     
4059='35'                     
4060='40'                     
4061='50'                     
4062='40'                     
4063='40'                     
4064='40'                     
4065='40'                     
4066='40'                     
4067='40'                     
4068='40'                     
4069='40'                     
4070='60'                     
4071='60'                     
4072='60'                     
4073='60'                     
4074='60'                     
4075='40'                     
4076='60'                     
4077='60'                     
4078='60'                     
4079='50'                     
4080='30'                     
4081='40'                     
4082='50'                     
4083='50'                     
4084='50'                     
4085='50'                     
4086='60'                     
4087='50'                     
4088='50'                     
4089='40'                     
4090='40'                     
4091='40'                     
4092='40'                     
4093='50'                     
4094='30' 
4095='30' 
4096='40'                     
4097='40'                     
4098='30'                     
4099='40'                     
4100='30'                     
4101='30' 
4103='30'  
4104='30' 
4105='30' 
4106='30' 
4107='30' 
4108='30' 
4109='30'
4110='30' 
4111='30' 
4112='30' 
4113='30' 
4114='30' 
4115='30' 
4116='30' 
4117='30' 
4118='30'                     
4119='30'                     
4120='30'                     
4121='30'                     
4122='30'                     
4123='30'                     
4124='30'                     
4125='30'                     
4126='30'                     
4127='30'                     
4128='30'                     
4129='30'                     
4134='40'                     
4135='30'  
4136='30'
4137='30'
4138='30'
4139='30' 
4140='30'                     
4141='30'                     
4142='30' 
4143='30'
4144='30' 
4145='30'
4146='30'
4147='30'
4148='30'
4149='30'
4150='30'
4151='30'
4152='30'
4153='30'
4154='30'
4155='30'
4156='30'
4157='30'
4158='30'
4159='30'
4160='30'
4161='30'
4162='30'
4163='30'
4164='30'
4165='30'
4166='30'                     
4168='30'   
4169='30' 
4170='30'
4171='30' 
4188='30'                     
4189='30' 
4190='30'
4191='30'
4192='30' 
4193='30'                     
4194='30'                     
4195='29'                     
4196='30'                     
4197='30'                     
4198='29'                     
4199='15'                     
4200='29'                     
4201='30'                     
4202='15'                     
4203='30'                     
4204='30'                     
4205='30'                     
4206='30'                     
4207='30'                     
4208='70'                     
4211='30'                     
4212='30'                     
4213='30'                     
4214='30'                     
4215='30'                     
4216='30'                     
4217='30'                     
4218='30'                     
4219='30'                     
4220='30'                     
4221='30'                     
4222='30'                     
4223='30'                     
4224='30'                     
4225='30'                     
4226='30'                     
4227='30'                     
4228='30'                     
4229='30'                     
4230='30'                     
4231='30'                     
4232='30'                     
4233='30'                     
4234='30'                     
4235='30'                     
4236='30'                     
4237='30'                     
4238='30'                     
4239='30'                     
4240='30'                     
4241='30'                     
4242='30'                     
4243='30'                     
4244='30'                     
4245='30'                     
4246='30'                     
4247='30'                     
4248='30'                     
4249='30'                     
425='40'                     
4250='30'                     
4251='30'                     
4252='30'                     
4253='30'                     
4254='30'                     
4255='30'                     
4256='30'                     
4257='30'                     
4258='30'                     
4259='30'                     
4260='30'                     
4261='30'                     
4262='30'                     
4263='30'                     
4264='30'                     
4265='30'                     
4266='30'                     
4267='30'                     
4268='30'                     
4269='30'                     
4270='30'                     
4271='30'                     
4272='30'                     
4273='30'                     
4274='30'                     
4275='30'                     
4276='30'                     
4277='30'                     
4278='30'                     
4279='30'                     
4280='30'                     
4281='30'                     
4282='30'                     
4283='30'                     
4284='30'                     
4285='30'                     
4286='30'                     
4287='30'                     
4288='30'                     
4289='30'                     
4290='30'                     
4291='30'                     
4292='30'                     
4293='30'                     
4294='30'                     
4295='30'                     
4296='30'                     
4297='30'                     
4298='30'                     
4299='30'                     
430='40'                     
4300='30'                     
4301='30'                     
4302='30'                     
4303='30'                     
4304='30'                     
4305='30'                     
4306='30'                     
4307='30'                     
4308='30'                     
4309='30'                     
4310='30'                     
4311='30'                     
4312='30'                     
4313='30'                     
4314='30'                     
4315='30'                     
4316='30'                     
4317='30'                     
4318='30'                     
4319='30'                     
4320='30'                     
4321='30'                     
4322='30'                     
4323='30'                     
4324='30'                     
4325='30'                     
4326='30'                     
4327='30'                     
4328='30'                     
4329='30'                     
4330='30'                     
4331='30'                     
4332='30'                     
4333='30'                     
4334='30'                     
4335='30'                     
4336='30'                     
4337='30'                     
4338='30'                     
4339='30'                     
4340='30'                     
4341='30'                     
4342='30'                     
4343='30'                     
4344='30'                     
4345='30'                     
4346='30'                     
4347='30'                     
4348='30'                     
4349='30'                     
4350='30'                     
4351='30'                     
4352='30'                     
4353='30'                     
4354='30'                     
4355='30'                     
4356='30'                     
4357='30'                     
4358='30'                     
4359='30'                     
4360='30'                     
4361='30'                     
4362='30'                     
4363='30'                     
4364='30'                     
4365='30'                     
4366='30'                     
4367='30'                     
4368='30'                     
4369='30'                     
4370='30'                     
4371='30'                     
4372='30'                     
4373='30'                     
4374='30'                     
4375='30'                     
4376='30'                     
4377='30'                     
4378='30'                     
4379='30'                     
4380='30'                     
4381='30'                     
4382='30'                     
4383='30'                     
4384='30'                     
4385='30'                     
4386='30'                     
4387='30'                     
4388='30'                     
4389='30'                     
439='40'                     
4390='30'                     
4391='30'                     
4392='30'                     
4393='30'                     
4394='30'                     
4395='30'                     
4396='30'                     
4397='30'                     
4398='30'                     
4399='30'                     
4400='30'                     
4401='30'                     
4402='30'                     
4403='30'                     
4404='30'                     
4405='30'                     
4406='30'                     
4407='30'                     
4410='30'                     
4411='30'                     
4412='30'                     
4413='30'                     
4414='30'                     
4415='30'                     
4416='30'                     
4417='30'                     
4418='30'                     
4419='30'                     
4420='30'                     
4421='30'                     
4422='30'                     
4423='30'                     
4424='30'                     
4425='30'                     
4426='30'                     
4427='30'                     
4428='30'                     
4429='30'                     
4430='30'                     
4431='30'                     
4432='30'                     
4433='30'                     
4434='30'                     
4435='30'                     
4436='30'                     
4437='30'                     
4438='30'                     
4439='30'                     
4440='30'                     
4441='30'                     
4442='30'                     
4443='30'                     
4444='30'                     
4445='30'                     
4446='30'                     
4447='30'                     
4448='30'                     
4449='30'                     
4450='50'                     
4451='30'                     
4452='30'                     
4453='30'                     
4454='30'                     
4455='30'                     
4456='30'                     
4457='30'                     
4458='30'                     
4459='30'                     
4460='30'                     
4461='30'                     
4462='30'                     
4463='30'                     
4464='30'                     
4465='30'                     
4466='30'                     
4467='30'                     
4468='30'                     
4469='30'                     
4470='30'                     
4471='30'                     
4472='30'                     
4473='30'                     
4474='50'                     
4475='30'                     
4476='30'                     
4477='30'                     
4478='30'                     
4479='30'                     
4480='30'                     
4481='30'                     
4482='30'                     
4483='30'                     
4484='30'                     
4485='30'                     
4486='30'                     
4487='30'                     
4488='30'                     
4489='30'                     
4490='30'                     
4491='30'                     
4492='30'                     
4493='30'                     
4494='30'                     
4495='30'                     
4496='30'                     
4497='30'                     
4498='30'                     
4499='30'                     
4500='30'                     
4501='30'                     
4502='30'                     
4503='30'                     
4504='30'                     
4505='30'                     
4506='30'                     
4507='30'                     
4508='30'                     
4509='30'                     
4510='30'                     
4511='30'                     
4512='30'                     
4513='30'                     
4514='30'                     
4515='30'                     
4516='30'                     
4517='30'                     
4518='30'                     
4519='30'                     
4520='30'                     
4521='30'                     
4522='30'                     
4523='30'                     
4524='30'                     
4525='30'                     
4526='30'                     
4527='30'                     
4528='30'                     
4529='30'                     
4530='30'                     
4531='30'                     
4532='30'                     
4533='30'                     
4534='30'                     
4535='30'                     
4536='30'                     
4537='30'                     
4538='30'                     
4539='30'                     
4540='30'                     
4541='30'                     
4542='30'                     
4543='30'                     
4544='30'                     
4545='30'                     
4546='30'                     
4547='30'                     
4548='30'                     
4549='30'                     
4550='30'                     
4551='30'                     
4552='30'                     
4553='30'                     
4554='30'                     
4555='30'                     
4556='30'                     
4557='30'                     
4558='30'                     
4559='30'                     
4560='30'                     
4561='30'                     
4562='40'                     
4563='30'                     
4564='30'                     
4565='30'                     
4566='30'                     
4567='30'                     
4568='30'                     
4570='30'                     
459='40'                     
4600='30'                     
4601='30'                     
4602='30'                     
4603='30'                     
4604='30'                     
4605='30'                     
4606='30'                     
4607='30'                     
4608='30'                     
4609='30'                     
4610='30'                     
4611='30'                     
4612='30'                     
4613='30'                     
4614='30'                     
4615='30'                     
4616='30'                     
4617='30'                     
4618='30'                     
4619='30'                     
4620='30'                     
4621='30'                     
4622='30'                     
4623='30'                     
4624='30'                     
4625='30'                     
4626='30'                     
4627='30'                     
4628='30'                     
4629='30'                     
4630='30'                     
4631='30'                     
4632='30'                     
4633='30'                     
4634='30'                     
4635='30'                     
4636='30'                     
4637='30'                     
4638='30'                     
4639='30'                     
4640='30'                     
4641='30'                     
4642='30'                     
4643='30'                     
4644='30'                     
4645='30'                     
4646='30'                     
4647='30'                     
4648='30'                     
4649='30'                     
4650='30'                     
4651='30'                     
4652='30'                     
4653='30'                     
4654='30'                     
4655='30'                     
4656='30'                     
4657='30'                     
4658='30'                     
4659='30'                     
4660='30'                     
4661='30'                     
4662='30'                     
4663='30'                     
4664='30'                     
4665='30'                     
4666='30'                     
4667='30'                     
4668='30'                     
4669='30'                     
4670='30'                     
4671='30'                     
4672='30'                     
4673='30'                     
4674='30'                     
4675='30'                     
4676='30'                     
4677='30'                     
4678='30'                     
4679='30'                     
4680='30'                     
4681='30'                     
4682='30'                     
4683='30'                     
4684='30'                     
4685='30'                     
4686='30'                     
4687='30'                     
4688='30'                     
4689='30'                     
4690='30'                     
4691='30'                     
4692='30'                     
4693='30'                     
4694='30'                     
4695='30'                     
4696='30'                     
4697='30'                     
4698='30'                     
4699='30'                     
4700='30'                     
4701='29'                     
4702='29'                     
4703='29'                     
4704='29'                     
4705='29'                     
4706='29'                     
4707='29'                     
4708='29'                     
4709='29'                     
4710='29'                     
4711='29'                     
4712='29'                     
4713='29'                     
4714='29'                     
4715='29'                     
4716='29'                     
4717='29'                     
4718='30'                     
4719='29'                     
4720='30'                     
4721='30'                     
4722='30'                     
4723='30'                     
4724='30'                     
4725='30'                     
4726='30'                     
4727='30'                     
4728='30'                     
4729='30'                     
4730='29'                     
4731='29'                     
4732='29'                     
4733='29'                     
4734='29'                     
4735='29'                     
4736='29'                     
4737='29'                     
4738='29'                     
4739='29'                     
4740='29'                     
475='40'                     
4750='30'                     
4754='30'                     
4755='30'                     
4756='30'                     
4757='30'                     
4758='30'                     
4759='30'                     
4760='30'                     
4762='30'                     
4780='30'                     
4781='30'                     
4782='30'                     
4783='30'                     
4784='30'                     
4785='30'                     
4786='30'                     
4787='30'                     
4788='30'                     
4789='30'                     
4790='30'                     
4791='30'                     
480='40'                     
4800='70'                     
4801='60'                     
485='40'                     
4850='30'                     
4851='30'                     
4853='30'                     
4854='30'                     
4855='30'                     
4856='30'                     
4858='30'                     
4859='30'                     
4860='30'                     
4861='30'                     
4864='30'                     
4865='30'                     
4866='30'                     
4867='30'                     
4868='30'                     
4869='30'                     
4870='30'                     
4871='30'                     
4874='30'                     
4875='30'                     
4876='30'                     
4877='30'                     
4878='30'                     
4879='30'                     
4880='30'                     
4881='30'                     
4882='30'                     
490='40'                     
4901='30'                     
4902='30'                     
4903='30'                     
4904='30'                     
4905='30'                     
4906='30'                     
4907='30'                     
4908='30'                     
4909='30'                     
4910='30'                     
4911='30'                     
4912='30'                     
4913='30'                     
4914='30'                     
4915='30'                     
4916='30'                     
4917='30'                     
4918='30'                     
4919='30'                     
4920='30'                     
4921='30'                     
4922='30'                     
4923='30'                     
4924='30'                     
4925='30'                     
4926='30'                     
4927='30'                     
4928='30'                     
4929='30'                     
4930='30'                     
4931='30'                     
4932='30'                     
4933='30'                     
4934='30'                     
4937='30'                     
4938='30'                     
4939='30'                     
4940='30'                     
4941='30'                     
4942='30'                     
4943='30'                     
4944='30'                     
4945='30'                     
4946='30'                     
495='40'                     
4951='30'                     
4952='30'                     
4953='30'                     
4954='30'                     
4955='30'                     
4956='30'                     
4957='30'                     
4958='30'                     
4959='30'                     
4960='30'                     
4961='30'                     
4962='30'                     
4963='30'                     
4964='30'                     
4965='30'                     
4966='30'                     
4967='30'                     
4968='30'                     
4969='30'                     
4970='30'                     
4971='30'                     
4977='30'                     
4978='30'                     
4979='30'                     
4980='30'                     
4981='30'                     
4982='30'                     
4983='30'                     
4984='30'                     
4985='30'                     
4986='30'                     
4987='30'                     
4988='30'                     
4989='30'                     
4990='30'                     
4991='30'                     
4992='30'                     
4995='30'                     
4996='30'                     
4997='30'                     
4998='30'                     
4999='40'                     
500='50'                     
5000='40'                     
5001='40'                     
5003='40'                     
5004='40'                     
5005='40'                     
5006='40'                     
5007='40'                     
5008='40'                     
5009='40'                     
5015='15'                     
5016='15'                     
5017='40'                     
5018='15'                     
5019='15'                     
5020='40'                     
5021='40'                     
5022='70'                     
5023='70'                     
5024='70'                     
5025='40'                     
5028='20'                     
5029='20' 
5030='40'  
5031='40'                     
5032='30'                     
5033='40'                     
5034='40'                     
5035='40'                     
5036='40'                     
5037='40'                     
5038='40'                     
5039='40'                     
5040='40'                     
5041='40'                     
5042='40'                     
5043='40'                     
5044='15'                     
5045='40'                     
5046='50'                     
5047='50'                     
5048='15'                     
5049='15'
5050='15' 
5051='15'                     
5052='15'                     
5053='15'                     
5054='15'                     
5055='60'                     
5056='70'                     
5057='70'                     
5058='70'                     
5059='70'                     
5060='50'                     
5061='40'                     
5062='70'                     
5063='70'                     
5064='70'                     
5065='40'                     
5066='40'                     
5067='40'                     
5068='40'                     
5069='40'                     
5070='40'                     
5071='40'                     
5072='40'                     
5073='40'                     
5074='40'                     
5075='50'                     
5076='40'                     
5077='40'                     
5078='40'                     
5079='40'                     
5080='20'                     
5081='20'                     
5082='40'                     
5083='40'                     
5084='40'                     
5085='40'                     
5086='40'                     
5087='40'                     
5088='20'                     
5090='20'                     
5091='15'                     
5092='20'                     
5093='40'                     
5094='40'                     
5095='40'                     
5096='40'                     
5097='20'                     
5098='20'                     
5100='40'                     
5101='70'                     
5102='70'                     
5103='70'                     
5104='70'                     
5105='70'                     
5106='70'                     
5107='70'                     
5108='70'                     
5109='70'                     
5110='40'                     
5111='50'                     
5112='50'                     
5113='50'                     
5114='50'                     
5115='50'                     
5116='50'                     
5117='50'                     
5118='50'                     
5119='50'                     
5120='50'                     
5121='40'                     
5122='40'                     
5123='40'                     
5124='40'                     
5125='40'                     
5126='35'                     
5127='50'                     
5128='50'                     
5129='40'                     
5130='40'                     
5131='40'                     
5132='40'                     
5133='40'                     
5134='40'                     
5135='40'                     
5136='40'                     
5137='40'                     
5138='50'                     
5139='40'                     
5140='40'                     
5141='40'                     
5142='30'                     
5143='40'                     
5144='30'                     
5145='30'                     
5146='30'                     
5147='30'                     
5148='30'                     
5149='30'                     
5150='40'                     
5151='50'                     
5152='30'                     
5153='50'                     
5154='50'                     
5155='30'                     
5156='40'                     
5157='50'                     
5158='50'                     
5159='50'                     
5160='50'                     
5161='50'                     
5162='40'                     
5163='40'                     
5164='40'                     
5165='60'                     
5166='50'                     
5167='50'                     
5168='50'                     
5169='50'                     
5170='50'                     
5171='50'                     
5172='50'                     
5173='50'                     
5174='40'                     
5175='50'                     
5176='50'                     
5177='40'                     
5178='50'                     
5179='50'                     
5180='70'                     
5181='50'                     
5182='30'                     
5183='30'                     
5184='40'                     
5185='30'                     
5186='30'                     
5187='50'                     
5188='50'                     
5189='50'                     
5190='50'                     
5191='50'                     
5192='50'                     
5193='50'                     
5194='50'                     
5195='40'                     
5196='40'                     
5197='40'                     
5198='40'                     
5199='40'                     
520='50'                     
5200='30'                     
5201='30'                     
5202='30'                     
5203='40'                     
5204='70'                     
5205='30'                     
5206='30'                     
5207='30'                     
5208='30'                     
5209='30'                     
5210='50'                     
5211='50'                     
5212='70'                     
5213='70'                     
5214='70'                     
5215='30'                     
5216='70'                     
5217='70'                     
5218='70'                     
5219='70'                     
5220='40'                     
5221='50'                     
5222='50'                     
5223='50'                     
5224='50'                     
5225='50'                     
5226='50'                     
5227='50'                     
5228='50'                     
5229='50'                     
5230='35'                     
5231='40'                     
5232='40'                     
5233='40'                     
5234='40'                     
5235='40'                     
5236='70'                     
5237='70'                     
5238='40'                     
5239='70'                     
5240='70'                     
5241='70'                     
5242='70'                     
5243='70'                     
5244='70'                     
5245='70'                     
5246='50'                     
5247='50'                     
5248='50'                     
5249='70'                     
525='50'                     
5250='50'                     
5251='50'                     
5252='50'                     
5253='50'                     
5254='50'                     
5255='50'                     
5256='50'                     
5257='50'                     
5258='50'                     
5259='50'                     
5260='40' 
5261='40'
5262='40'
5263='70'  
5264='40' 
5265='70'                     
5266='50'                     
5267='50'                     
5268='50'                     
5269='50'                     
5270='50'                     
5271='70'                     
5272='70'                     
5273='70'                     
5274='70'                     
5275='50'                     
5276='50'                     
5277='50'                     
5278='50'                     
5279='50'                     
5280='50'                     
5281='50'                     
5282='50'                     
5283='50'                     
5284='50'                     
5285='70'                     
5286='70'                     
5295='40'                     
5298='35'                     
5299='35'                     
530='50'                     
5300='50'                     
5301='50'                     
5302='50'                     
5303='50'                     
5304='50'                     
5305='50'                     
5306='50'                     
5307='50'                     
5308='50'                     
5309='50'                     
5310='50'                     
5311='50'                     
5312='50'                     
5313='50'                     
5314='50'                     
5315='50'                     
5316='50'                     
5317='50'                     
5318='50'                     
5319='50'                     
5320='50'                     
5321='50'                     
5322='50'                     
5323='50'                     
5324='50'                     
5325='50'                     
5326='50'                     
5327='50'                     
5328='50'                     
5329='50'                     
5330='50'                     
5331='50'                     
5332='50'                     
5333='50'                     
5334='50'                     
5335='50'                     
5336='50'                     
5337='50'                     
5338='50'                     
5339='50'                     
5340='50'                     
5341='50'                     
5342='50'                     
5343='50'                     
5344='50'                     
5345='50'                     
5346='50'                     
5347='50' 
5348='50'  
5349='50'                     
5350='50'                     
5351='50'                     
5352='50'                     
5353='50'                     
5354='50'                     
5355='50'                     
5356='50'                     
5357='50'                     
5358='50'                     
5359='50'                     
5360='70'                     
5361='70'                     
5362='70'                     
5363='70'                     
5364='70'                     
5365='70'                     
5366='70'                     
5367='70'                     
5368='70'                     
5369='70'                     
5370='70'                     
5371='70'                     
5372='70'                     
5373='70'                     
5374='70'                     
5375='70'                     
5376='70'                     
5377='70'                     
5378='70'                     
5379='70'                     
5380='70'                     
5381='70'                     
5382='70'                     
5383='70'                     
5384='70'                     
5385='70'                     
5386='70'                     
5387='70'                     
5388='70'                     
5389='70'                     
539='50'                     
5390='70'                     
5391='70'                     
5392='70'                     
5393='70'                     
5394='70'                     
5395='70'                     
5396='70'                     
5397='70'                     
5398='70'                     
5399='80'                     
5400='70'                     
5401='70'                     
5402='70'                     
5403='70'                     
5404='70'
5405='70' 
5406='70'
5407='70' 
5408='70'                     
5409='70'                     
5410='70'
5411='70' 
5412='70'                     
5413='70'                     
5414='70'                     
5415='70'                     
5416='80'                     
5417='80'  
5418='80' 
5419='70'                     
5420='70'                     
5421='70'                     
5422='70'                     
5423='70'                     
5424='50'                     
5425='70'                     
5426='50'                     
5427='80'                     
5428='70'                     
5429='50'                     
5430='70'                     
5431='50'                     
5432='40'                     
5433='70'                     
5434='50'                     
5435='80'                     
5436='50'                     
5437='50'                     
5438='50'                     
5439='50'                     
5440='50'                     
5441='50'                     
5442='50'                     
5443='30'                     
5444='50'                     
5445='50'                     
5446='50'                     
5447='50'                     
5448='70'                     
5449='70'                     
545='50'                     
5450='50'                     
5451='50'                     
5452='70'                     
5453='70'                     
5454='70'                     
5455='70'                     
5456='50'                     
5457='50'                     
5458='50'                     
5459='50'                     
5460='50'                     
5461='50'                     
5462='50'                     
5463='60'                     
5464='80'                     
5465='70'                     
5467='50'                     
5468='70'                     
5469='50'                     
5470='70'                     
5471='50'                     
5472='50'                     
5473='50'                     
5475='50'                     
5476='50'                     
5477='50'                     
5478='50'                     
5479='50'                     
5480='80'                     
5481='50'                     
5482='50'                     
5483='50'                     
5484='50'                     
5485='50'                     
5486='50'                     
5487='50'                     
5488='50'                     
5489='50'                     
5490='50'                     
5491='50'                     
5492='50'                     
5493='40'                     
5494='50'                     
5495='40'                     
5496='40'                     
5497='50'                     
5498='50'                     
5499='50'                     
5500='50'                     
5501='50'                     
5502='50' 
5503='50' 
5505='50' 
5506='50' 
5507='50' 
5508='50'                     
5511='50'                     
5512='50'                     
5513='50'                     
5514='50'                     
5515='50'                     
5516='50'                     
5517='50'                     
5518='50'                     
5519='50'                     
5520='50'                     
5521='50'                     
5522='50'                     
5523='50'                     
5524='50'                     
5525='50'                     
5526='50'                     
5527='50'                     
5528='50'                     
5529='50'                     
5530='50'                     
5531='50'                     
5532='70'                     
5533='70'                     
5534='70'                     
5535='70'                     
5536='70'                     
5537='70'                     
5541='50'                     
5542='50'                     
5543='50'                     
5545='50'                     
5546='50'                     
5547='50'                     
5550='50'                     
5551='50'                     
5552='50'                     
5553='50'                     
5555='50'                     
5556='50'                     
5557='50'                     
5561='50'                     
5562='50'                     
5563='50'                     
5564='50'                     
5565='50'                     
5566='50'                     
5571='70'                     
5572='70'                     
5575='50'                     
5576='70'                     
5577='70'                     
5578='70'                     
5580='80'                     
5581='50'                     
5582='50'                     
5583='50'                     
5586='50'                     
5587='50'                     
5589='70'                     
559='50'                     
5590='70'                     
5591='70'                     
5592='70'                     
5593='70'                     
5594='70'                     
5595='70'                     
5596='70'                     
5597='70'                     
5598='70'                     
5599='70'                     
5600='50'
5601='50' 
5602='50'                     
5603='50' 
5604='50' 
5605='50'
5606='60'                     
5607='60'                     
5608='70'                     
5609='70'
5610='70' 
5611='80'                     
5615='80'                     
5616='70' 
5617='70'  
5618='80'                     
5619='80'                     
5620='80'                     
5621='70'                     
5622='70'                     
5623='70'                     
5624='70'                     
5630='40'                     
5631='40'                     
5632='40'                     
5633='40'                     
5635='40'                     
5636='40'                     
5637='40'                     
5651='60'                     
5652='70'                     
5653='70'                     
5654='60'                     
5656='60'                     
5657='70'                     
5658='70'                     
5661='60'                     
5662='70'                     
5663='60'                     
5666='60'                     
5667='70'                     
5670='50'                     
5671='50'                     
5672='50'                     
5673='50'                     
5674='50'                     
5675='50'                     
5676='50'                     
5677='50'                     
5678='50'                     
5679='50'                     
5680='70'                     
5681='50'                     
5682='50'                     
5683='50'                     
5684='50'                     
5685='50'                     
5686='50'                     
5687='50'                     
5688='50'                     
5689='50'                     
5690='50'                     
5691='50'                     
5692='50'                     
5693='50'                     
5694='50'                     
5695='50'                     
5696='50'                     
5697='50'                     
5698='50'                     
5700='60'                     
5701='60'                     
5702='60'                     
5703='70'                     
5704='60'                     
5705='80'                     
5706='50'                     
5707='50'                     
5708='70'                     
5709='60'                     
5710='50'                     
5711='60'                     
5712='60'                     
5713='60'                     
5714='60'                     
5715='50'                     
5716='60'                     
5717='70'                     
5718='60'                     
5719='50'                     
5720='50'                     
5721='50'                     
5722='50'                     
5723='50'                     
5724='50'                     
5725='50'                     
5726='50'                     
5727='50'                     
5728='50'                     
5729='50'                     
5730='50'                     
5731='50'                     
5732='50'                     
5733='60'                     
5734='60'                     
5735='50'                     
5736='50'                     
5737='70'                     
5738='70'                     
5739='70'                     
5740='70'                     
5741='70'                     
5742='70'                     
5743='70'                     
5744='70'                     
5745='80'                     
5746='50'                     
5747='50'                     
5748='50'                     
5749='50'                     
575='50'                     
5750='70'                     
5751='70'                     
5752='70'                     
5753='70'                     
5754='70'                     
5755='50'                     
5756='70'                     
5757='70'                     
5758='70'                     
5759='70' 
5760='70' 
5761='70'                     
5762='70'                     
5763='70'                     
5764='60'                     
5766='50'                     
5767='50'                     
5768='50'                     
5769='60'                     
5770='70'                     
5771='70'                     
5772='70'                     
5773='70'                     
5774='70'                     
5776='50'                     
5777='50'                     
5778='50'                     
5779='70'                     
5780='60'                     
5781='60'                     
5782='70'                     
5783='60'                     
5784='70'                     
5785='70'                     
5786='70'                     
5787='70'                     
5788='70'                     
5789='70'                     
5790='50'                     
5791='50'                     
5792='70'                     
5793='70'                     
5794='70'                     
5795='70'                     
5796='70'                     
5797='60'                     
5798='70'                     
580='50' 
5800='50' 
5801='50'                     
5802='50'                     
5803='50'                     
5804='50'                     
5805='50'                     
5806='50'                     
5807='50'                     
5808='50'                     
5809='70'                     
5810='70'                     
5811='70'                     
5812='70'                     
5813='60'                     
5814='50' 
5815='50' 
5816='50'                     
5817='50'                     
5818='50'                     
5819='60'                     
5820='70'                     
5821='70'                     
5822='70'                     
5823='70'                     
5824='70'                     
5825='70'                     
5826='60'                     
5827='60'                     
5828='60'                     
5829='60'                     
5830='40'                     
5831='60'                     
5832='70'                     
5833='60'                     
5834='60'  
5835='60'    
5836='60'                     
5837='60'                     
5838='60'                     
5839='80'                     
5840='70'                     
5841='70'                     
5842='70'                     
5843='70'                     
5844='70'   
5845='50'  
5846='50'                     
5847='50'                     
5848='50'                     
5849='50'                     
585='50'                     
5850='50'                     
5851='50'                     
5852='50'                     
5855='50'                     
5856='50'                     
5857='50'                     
5858='70'                     
5859='50'                     
5860='50'                     
5865='50'                     
5866='50'                     
5867='50'                     
5868='50'                     
5869='50'                     
5870='50'                     
5871='50'                     
5872='50'                     
5875='70'                     
5877='70'                     
5880='70'                     
5885='70'                     
5886='70'                     
5889='70'                     
5890='70'                     
5895='40'                     
5899='60'                     
590='50'                     
5900='70'                     
5901='70'                     
5902='70'                     
5903='70'                     
5904='40'                     
5905='60'                     
5906='70'                     
5907='60'                     
5908='60'                     
5909='70' 
5910='60' 
5911='60'                     
5912='60'                     
5913='70'                     
5914='50'                     
5915='50'                     
5916='70'                     
5917='70'                     
5918='70'                     
5919='80'
5920='50' 
5921='50'                     
5922='70'                     
5923='60'                     
5924='70'                     
5925='70'                     
5926='70'                     
5927='60'                     
5928='60'                     
5929='70'                     
5931='60'                     
5932='60'                     
5933='60'                     
5934='60'                     
5935='60'                     
5936='60'                     
5937='60'                     
5938='60'                     
5939='60'                     
5940='60'                     
5941='60'                     
5942='60'                     
5943='60'                     
5944='60'                     
5945='60'                     
5946='60'                     
5947='60'                     
5948='60'                     
5949='60'                     
595='50'                     
5950='60'                     
5951='60'                     
5952='60'                     
5953='60'                     
5954='60'                     
5955='60'                     
5956='60'                     
5957='60'                     
5958='60'                     
5959='60'                     
5960='60'                     
5961='60'                     
5962='70'                     
5963='70'                     
5964='70'                     
5965='70'                     
5966='70'                     
5967='70'                     
5968='70'                     
5969='70'                     
5970='60'                     
5971='60'                     
5972='60'                     
5973='60'                     
5974='60'                     
5975='60'                     
5976='60'                     
5977='60'                     
5978='60'                     
5979='60'                     
5980='60'                     
5981='60'                     
5982='60'                     
5983='60'                     
5984='60'                     
5985='60'                     
5986='60'                     
5987='60'                     
5988='60'                     
5989='60'                     
5990='60'                     
5991='60'                     
5992='60'                     
5993='60'                     
5994='60'                     
5995='60'                     
5996='70'                     
600='70'                     
6000='70'                     
6001='60'                     
6002='60'                     
6003='60'                     
6004='60'                     
6005='60'                     
6006='60'                     
6007='60'                     
6008='60' 
6009='70' 
6010='70'  
6011='70'                     
6012='70'                     
6013='70'                     
6014='70'                     
6015='70'                     
6016='70'                     
6017='60'                     
6018='60'                     
6020='40'                     
6021='40'                     
6022='30'                     
6023='30'                     
6024='30'                     
6025='30'                     
6026='40'                     
6027='50'                     
6029='70'                     
6030='60'                     
6031='70'                     
6040='60'                     
6045='60'                     
6046='60'                     
6047='60'                     
6048='60'                     
6050='60'                     
6051='60'                     
6055='70'   
6061='70' 
6062='70'
6063='70' 
6064='70'                     
6065='70' 
6070='70' 
6071='70'
6075='70' 
6076='70'                     
6077='70'
6080='70' 
6081='70'                     
6082='70'
6083='60'
6084='60'
6085='70' 
6086='70'                     
6087='70'                     
6100='70'                     
6101='60'                     
6102='60'                     
6103='60'                     
6104='70'                     
6105='70'                     
6106='70'                     
6107='60'                     
6108='60'                     
6109='60'                     
6110='60'                     
6111='70'                     
6112='70'                     
6113='70'                     
6114='70'                     
6115='60'                     
6116='60'                     
6117='60'                     
6118='60'                     
6119='70'                     
6120='70'                     
6121='70'                     
6125='70'                     
6126='70'                     
6127='70'                     
6128='70'                     
6129='70'                     
6130='70'                     
6131='70'                     
6132='70'                     
6133='70'                     
6134='70'                     
6135='70'                     
6136='70'                     
6137='70'                     
6138='70'                     
6139='70'                     
6140='70'                     
6141='70'                     
6142='70'                     
6143='70'                     
6144='70'                     
6145='70'                     
6146='70'                     
6147='70'                     
6148='70'                     
6149='70'                     
6150='70'                     
6151='60'                     
6152='60'                     
6153='70'                     
6154='60'                     
6155='60'                     
6156='60'                     
6157='60'                     
6158='70'                     
6159='70'                     
6161='60'                     
6162='60'                     
6163='60'                     
6164='60'                     
6165='60'                     
6166='60'                     
6167='70'                     
6168='70'                     
6169='70'                     
6170='70'                     
6171='70'                     
6172='70'                     
6173='70'                     
6174='70'                     
6175='70'                     
6176='70'                     
6177='70'                     
6178='70'                     
6179='70'                     
6181='70'                     
6182='70'                     
6183='70'                     
6184='70'                     
6185='70'                     
6186='70'                     
6187='70'                     
6188='70'                     
6189='70'                     
620='70'                     
6200='70' 
6230='70'
6231='70'
6233='70' 
6235='70' 
6237='70' 
6239='70'
6241='70'
6242='60'                     
6243='70'                     
6244='70'                     
6245='70'                     
6246='70'                     
6247='70'                     
625='70'                     
6260='70'                     
6261='70'                     
6262='70'                     
6263='70'                     
6264='70'                     
6265='70'                     
6266='70'                     
6267='70'                     
6268='70'                     
6269='70'                     
6270='70'                     
6271='70'                     
6282='70'                     
6285='70'                     
6296='70'                     
6297='70'                     
6298='60'                     
6299='60'                     
630='70' 
6300='70'  
6302='70'
6303='70'
6304='70'
6305='70'
6306='70'
6307='70'
6308='70'
6309='70'
6310='70'
6311='70'
6312='70'
6313='70'   
6314='70' 
6315='70' 
6316='70' 
6317='70' 
6318='70' 
6319='70' 
6320='70'  
6321='70'                     
6322='70' 
6323='70' 
6324='70' 
6325='70' 
6326='70' 
6327='70' 
6328='70'
6329='70'
6330='70' 
6331='70'
6332='70'
6333='70'
6334='70'
6335='70'
6336='70'
6337='70' 
6338='70'
6340='70'  
6342='70' 
6343='70' 
6344='70'
6346='70' 
6347='70' 
6348='70' 
6349='70' 
6350='70' 
6351='70' 
6352='70'
6353='70'  
6380='70'                     
6381='70'                     
6382='70'                     
6383='70'                     
6384='70'                     
6385='70'                     
639='70'                     
6393='70'                     
6394='70'                     
6395='70'                     
6396='70'                     
6397='70'                     
6398='70'                     
6399='70'
6400='70' 
6401='70'                     
6402='70'                     
6403='60'                     
6404='60'                     
6405='60'                     
6406='60'                     
6407='70'                     
6408='70'                     
6409='70'                     
6410='70' 
6411='70'
6412='70' 
6413='70'                     
6414='70'                     
6415='70'                     
6416='70'                     
6417='70'                     
6418='70'                     
6419='70'                     
6420='70'                     
6421='70' 
6422='70'
6423='70' 
6424='70'                     
6425='70'                     
6426='70'                     
6427='70'                     
6428='70' 
6429='70'
6430='70' 
6431='70' 
6432='70' 
6433='70' 
6434='70' 
6435='70' 
6436='70' 
6437='70' 
6438='70' 
6439='70'
6440='70' 
6441='70'
6442='70'
6443='70'
6444='70'
6445='70'
6446='70'
6447='70'
6448='70'
6449='70' 
645='70'  
6450='70' 
6451='70'    
6452='70'
6453='70'    
6454='70'                     
6455='70'                     
6456='70'                     
6457='70'                     
6458='70'                     
6459='70' 
6460='70' 
6461='70'                     
6462='70'                     
6490='70'                     
6491='70'                     
6492='70'                     
6493='70'                     
6494='70'                     
6495='60'                     
6496='60'                     
6497='60'                     
6500='60'                     
6501='70'                     
6502='60'                     
6503='70'                     
6504='60'                     
6505='60'                     
6506='60'                     
6507='60'                     
6508='60'                     
6509='60'                     
6510='60'                     
6511='70'                     
6512='60'                     
6513='70'                     
6514='70'                     
6515='70'                     
6516='60'                     
6517='70'                     
6518='60'                     
6519='70'                     
6520='60'                     
6521='70'                     
6522='60'                     
6523='70'                     
6524='60'                     
6525='70'                     
6526='60'                     
6527='70'                     
6528='60'                     
6529='70'                     
6530='60'                     
6531='70'                     
6532='60'                     
6533='70'                     
6534='60'                     
6535='70'                     
6536='60'                     
6537='70'                     
6538='60'                     
6539='70'                     
6540='60'                     
6541='70'                     
6542='60'                     
6543='70'                     
6544='60'                     
6545='70'                     
6546='60'                     
6547='70'                     
6548='60'                     
6549='70'                     
6550='60'                     
6551='70'                     
6552='60'                     
6553='70'                     
6554='60'                     
6555='60'                     
6556='60'                     
6557='70'                     
6558='60'                     
6559='60'                     
6560='60'                     
6561='60'                     
6562='60'                     
6563='70'                     
6564='60'                     
6565='70'                     
6566='60'                     
6567='70'                     
6568='60'                     
6569='70'                     
6570='60'                     
6571='70'                     
6572='70'                     
6573='70'                     
6574='60'                     
6575='70'                     
6576='60'                     
6577='70'                     
6578='60'                     
6579='70'                     
6580='60'                     
6581='70'                     
6582='60'                     
6583='70'                     
6584='60'                     
6585='70'                     
6586='60'                     
6587='70'                     
6588='60'                     
6589='70'                     
659='70'                     
6590='60'                     
6591='70'                     
6592='60'                     
6593='70'                     
6594='60'                     
6595='70'                     
6596='60'                     
6597='70'                     
6598='60'                     
6599='70'                     
6600='60'                     
6601='70'                     
6602='60'                     
6603='70'                     
6604='60'                     
6605='70'                     
6606='60'                     
6607='70'                     
6608='60'                     
6609='70'                     
6610='60'                     
6611='70'                     
6612='60'                     
6613='70'                     
6614='60'                     
6615='70'                     
6616='60'                     
6617='70'                     
6618='60'                     
6619='70'                     
6620='60'                     
6621='70'                     
6622='60'                     
6623='70'                     
6625='70'                     
6627='70'                     
6629='70'                     
6631='70'                     
6632='60'                     
6633='70'                     
6634='60'                     
6635='60'                     
6636='60'                     
6637='70'                     
6638='60'                     
6639='70'                     
6640='60'                     
6641='70'                     
6642='60'                     
6643='70'                     
6644='60'                     
6645='70'                     
6646='60'                     
6647='70'                     
6649='70'                     
6650='60'                     
6651='70'                     
6652='60'                     
6653='70'                     
6655='70'                     
6657='70'                     
6659='70'                     
6661='70'                     
6665='60'                     
6666='60'                     
6667='70'                     
6668='60'                     
6669='70'                     
6670='60'                     
6671='70'                     
6672='60'                     
6673='60'                     
6674='60'                     
6675='60'                     
6676='60'                     
6677='70'                     
6679='60'                     
6680='60'                     
6681='60'                     
6682='60'                     
6683='60'                     
6684='60'                     
6685='60'                     
6686='60'                     
6687='60'                     
6688='60'                     
6689='60'                     
6690='60'                     
6691='60'                     
6692='60'                     
6693='60'                     
6694='60'                     
6695='60'                     
6696='60'                     
6697='60'                     
6698='60'                     
6700='70'                     
6701='70'                     
6702='70'                     
6703='70'                     
6704='70'                     
6705='70'                     
6706='70'                     
6707='70'                     
6708='70'                     
6709='70'                     
6710='70'                     
6711='70'                     
6712='70'                     
6713='70'                     
6714='70'                     
6715='70'                     
6716='70'                     
6717='70'                     
6718='70'                     
6719='70'                     
6720='70'                     
6721='70'                     
6722='70'                     
6723='70'                     
6724='70'                     
6725='70'                     
6726='70'                     
6727='70'                     
6729='70'                     
6730='70'                     
6731='70'                     
6732='70'                     
6733='70'                     
6734='70'                     
6735='70'                     
6737='70'                     
6738='70'                     
6739='70'                     
6740='70'                     
6741='70'                     
6742='70'                     
6743='70'                     
6744='70'                     
6745='70'                     
6746='70'                     
6747='70'                     
6749='70'                     
675='70'                     
6750='70'                     
6751='70'                     
6753='70'                     
6754='70'                     
6757='70'                     
6758='70'                     
6760='70'                     
6762='70'                     
6763='70'                     
6765='70'                     
6766='70'                     
6767='70'                     
6768='70'                     
6769='70'                     
6771='70'                     
6773='70'                     
6774='70'                     
6775='70'                     
6777='70'                     
6778='70'                     
6779='70'                     
6781='70'                     
6782='70'                     
6783='70'                     
6785='70'                     
6786='70'                     
6787='70'                     
6789='70'                     
6790='70'                     
6791='70'                     
6793='70'                     
6795='70'                     
6797='70'                     
680='70'                     
6800='70'                     
6801='70'                     
6802='70'                     
6803='70'                     
6804='70'                     
6805='70'                     
6806='70'                     
6807='70'                     
6808='70'                     
6809='70'                     
6810='50'                     
6811='70'                     
6813='70'                     
6814='70'                     
6815='70'                     
6816='70'                     
6817='70'                     
6818='70'                     
6819='70'                     
6820='70'                     
6821='70'                     
6822='70'                     
6823='70'                     
6824='70'                     
6825='70'                     
6827='70'                     
6829='70'                     
6831='70'                     
6832='70'                     
6833='70'                     
6836='70'                     
6837='70'                     
6838='70'                     
6839='70'                     
6840='70'                     
6841='70'                     
6842='70'                     
6843='70'                     
6845='70'                     
6846='70'                     
6847='70'                     
6849='70'                     
6851='70'                     
6853='70'                     
6855='70'                     
6857='70'                     
6859='70'                     
6860='70'                     
6861='70'                     
6862='70'                     
6863='70'                     
6864='70'                     
6865='70'                     
6867='70'                     
6868='70'                     
6869='70'                     
6870='70'                     
6871='70'                     
6872='70'                     
6873='70'                     
6874='70'                     
6875='70'                     
6876='70'                     
6877='70'                     
6878='70'                     
6880='70'                     
6881='70'                     
6885='70'                     
6886='70'                     
6887='70'                     
6888='70'                     
6890='70'                     
6891='70'                     
6892='70'                     
6893='70'                     
6894='70'                     
6895='70'                     
6896='70'                     
6897='70'                     
6898='70'                     
690='70'                     
6900='70'                     
6901='70'                     
6902='70'                     
6903='70'                     
6904='70'                     
6905='70'                     
6906='70'                     
6908='70'                     
6910='70'                     
6912='70'                     
6913='70'                     
6914='70'                     
6915='70'                     
6920='70'                     
6925='70'                     
6930='70'                     
6940='70'                     
6941='70'                     
6942='70'                     
695='70'                     
6987='70'                     
6990='70'                     
6991='70'                     
6992='70'                     
700='60'                     
7003='70'                     
7005='70'                     
7006='60'                     
7007='60'                     
7008='60'                     
7009='60'                     
7011='70'                     
7012='70'                     
7013='60'                     
7014='60'                     
7015='60'                     
7016='60'                     
7017='60'                     
7018='60'                     
7019='60'                     
702='60'                     
7020='60'                     
7021='70'                     
7022='70'                     
7023='70'                     
7024='70'                     
7025='70'                     
7026='70'                     
7027='70'                     
7028='70'                     
703='60'                     
7030='80'                     
704='60' 
7040='70' 
7045='70'                     
705='60'                     
7050='80'                     
706='60'  
7060='70' 
7061='60'                     
7062='60'                     
7063='70'                     
7065='70'                     
707='60'                     
7070='80'                     
7079='70'                     
708='60' 
7080='70'  
7081='60'                     
7085='70'                     
7086='70'                     
709='60'                     
7090='80'                     
7100='60'                     
7101='70'                     
7102='70'                     
7103='60'                     
7104='60'                     
7105='70'                     
7106='70'                     
7107='70'                     
7108='60'                     
7109='60'                     
7110='70'                     
7111='70'                     
7112='70'                     
7113='70'                     
7114='70'                     
7115='70'                     
7116='70'                     
7117='70'                     
7118='70'                     
7119='70'                     
7120='80'                     
7121='60'                     
7122='60'                     
7123='60'                     
7124='60'                     
7125='60'                     
7126='60'                     
7127='60'                     
7128='60'                     
7129='60'  
7130='70' 
7131='60'                     
7132='60'                     
7133='70'                     
7134='60'                     
7135='70'                     
7136='70'                     
7137='60'                     
7138='70'                     
7139='70'                     
7140='80'                     
7141='70'                     
7142='70'                     
7143='70'                     
7144='70'                     
7145='70'                     
7146='70'                     
7147='70'                     
7148='70' 
7150='70'  
7151='70'                     
7153='60'                     
7155='70'                     
7156='60'                     
7157='60'                     
7158='60'                     
7159='60'                     
7160='80'                     
7161='60'                     
7162='60'                     
7163='60'                     
7164='60'                     
7165='60'                     
7166='60'                     
7167='60'                     
7168='60'                     
7170='70'
7171='70'  
7172='60'                     
7173='70'                     
7174='70'                     
7175='70'                     
7176='60'                     
7177='60'                     
7178='60'                     
7179='60'                     
7180='80'                     
7181='70'                     
7182='60'                     
7183='70'                     
7184='60'                     
7185='70'                     
7186='60'                     
7187='70'                     
7188='70'                     
7189='70'                     
7190='80'                     
7191='60'                     
7192='60'                     
7193='60'                     
7194='60'                     
7195='70'                     
7196='60'                     
7197='60'                     
7198='60'                     
7199='60'                     
720='80'                     
7200='80'                     
7203='70' 
7205='70' 
7207='70'                     
7208='60'                     
7209='60'                     
721='80'                     
7210='60'                     
7211='60'                     
7213='70'                     
7215='60'                     
7216='70'                     
7217='70'                     
7218='70'                     
7219='70'                     
722='80'                     
7220='70'                     
7223='70'                     
7224='70'                     
7225='70'                     
7226='70'                     
7227='70'                     
723='80'                     
7230='70'                     
7231='60'                     
7232='70'                     
7235='80'                     
7236='70'                     
7237='70'                     
7238='70'                     
7239='70'                     
724='80'                     
7243='70'                     
725='80'                     
7253='70'                     
726='80'                     
7263='70'                     
7279='70'                     
728='80'                     
729='80'                     
7298='70'                     
7303='70'                     
7313='70'                     
7314='70' 
7320='70'  
7321='70'                     
7322='60'                     
7323='70'                     
7324='60'                     
7325='60'                     
7333='70'                     
7335='80'                     
7336='70'                     
7343='70'                     
7344='70'                     
7345='70'                     
7348='70'                     
7353='70' 
7360='70'  
7362='70'                     
7363='70'                     
7364='70'                     
7365='80'                     
7373='70'                     
7383='70'                     
7395='70'                     
7396='70'                     
7397='70'                     
7398='70'                     
7399='70'                     
7400='70'                     
7401='70'                     
7402='70'                     
7403='70'                     
7415='60'                     
7420='60'                     
7423='70'                     
7424='70'                     
7425='70'                     
7426='70'                     
7427='70'                     
7430='70'                     
7438='70'                     
7458='70'                     
7468='70'                     
7478='70'                     
7484='70'                     
7488='70'                     
7489='70'                     
7518='70'                     
7527='70'                     
7537='70'                     
7547='70'                     
7557='70'                     
7567='70'                     
7578='70'                     
7588='70'                     
7598='70' 
7600='70' 
7601='70'                     
7602='70'                     
7607='70'                     
7608='70'                     
7620='70'                     
7621='60'                     
7628='70'                     
7653='70'                     
7667='40'                     
7668='70'                     
7673='70'                     
7683='70'                     
7693='70'                     
7723='70'                     
7733='70'                     
7743='70'                     
7745='70'                     
7746='70'                     
7747='70'                     
7748='70'                     
7749='70'                     
7750='70'                     
7751='70'                     
7752='70'                     
7753='70'                     
7754='70'                     
7776='70'                     
7779='70'                     
7802='70'                     
7804='70'                     
7813='70'                     
7832='70'                     
7833='70'
7840='70' 
7841='60'                     
7842='70'                     
7843='60'                     
7844='70'                     
7845='60'                     
7846='60'                     
7847='60'                     
7848='60'                     
7849='60'                     
7850='60'                     
7851='60'                     
7852='60'                     
7853='60'                     
7854='60'                     
7855='60'                     
7856='60'                     
7857='60'                     
7858='60'                     
7859='60'                     
7860='60'                     
7861='70'                     
7862='70'                     
7863='70'                     
7864='80'                     
7865='70'                     
7873='70'                     
7883='70'  
7885='70' 
7887='70'                     
7893='70'                     
7900='60'                     
7901='60'                     
7902='60'                     
7903='70'                     
7904='60'                     
7905='60'                     
7906='60'                     
7907='60'                     
7908='60'                     
7909='60'                     
7910='60'                     
7911='60'                     
7912='60'                     
7913='70'                     
7914='60'                     
7915='60'                     
7916='60'                     
7917='60'                     
7918='60'                     
7919='60'                     
7920='60'                     
7921='60'                     
7922='60'                     
7923='60'                     
7924='60'                     
7925='60'                     
7926='60'                     
7927='60'                     
7928='60'                     
7929='60'                     
7930='60'                     
7931='60'                     
7932='60'                     
7933='60'                     
7934='60'                     
7935='60'                     
7936='60'                     
7937='60'                     
7938='60'                     
7939='60'                     
7940='60'                     
7941='70'                     
7942='60'                     
7943='60'                     
7944='60'                     
7945='70'                     
7946='70'                     
7947='70'                     
7948='60'                     
7949='70'                     
7950='70'                     
7951='60'                     
7952='70'                     
7953='60'                     
7954='70'                     
7955='70'                     
7956='70'                     
7957='70'                     
7958='60'                     
7959='70'                     
7960='80'                     
7961='70'                     
7965='80'                     
7970='80'                     
7971='60'                     
7972='60'                     
7973='60'                     
7995='70'                     
800='40'                     
8000='80'                     
8001='70'                     
8002='70'                     
8003='70'                     
8004='70'                     
8005='70'                     
8006='70'                     
8007='70'                     
8008='70'                     
8009='70'                     
8010='70'                     
8011='70'                     
8012='70'                     
8013='70'                     
8014='70'                     
8015='70'                     
8016='70'                     
8017='70'                     
8018='70'                     
8019='70'                     
802='50'                     
8020='70'                     
8021='60'                     
8022='70'                     
8023='70'                     
8024='70'                     
8025='70'                     
8026='60'                     
803='40'                     
8031='70'                     
8032='70'                     
8033='70'                     
8034='70'                     
8035='70'                     
8036='70'                     
8037='70'                     
8038='70'                     
8039='60'                     
8040='60'                     
8041='60'                     
8042='60'                     
8043='70'                     
8044='60'                     
8045='60'                     
8049='60'                     
805='30'                     
8050='60'                     
8052='60'                     
8059='60'                     
806='40'                     
8060='70'                     
807='40'                     
8073='70'                     
8074='70'                     
8075='60'                     
8076='70'                     
8077='70'                     
8078='70'                     
8079='70'                     
8080='70'                     
8081='70'                     
8082='70'                     
8083='70'                     
8084='70'                     
8085='70'                     
8086='70'                     
8087='70'                     
8088='70'                     
8089='70'                     
8090='70'                     
8091='70'                     
8092='70'                     
8093='70'                     
8094='70'                     
8095='70'                     
8096='70'                     
8097='70'                     
8098='70'                     
8099='70'                     
810='50'                     
8100='60'                     
8101='60'                     
8102='60'                     
8103='60'                     
8104='60'                     
8105='60'                     
8106='60'                     
8107='60'                     
8108='60'                     
8109='60'                     
811='40'                     
8110='60'                     
8111='60'                     
8112='60'                     
8113='60'                     
8114='60'                     
8116='60'                     
8117='70'                     
8118='70'                     
8119='60'                     
812='30'                     
8120='60'                     
8121='60'                     
8122='60'                     
8123='60'                     
8124='60'                     
8125='60'                     
8126='60'                     
8129='60'                     
8130='60'                     
8131='70'                     
8132='60'                     
8133='60'                     
8134='60'                     
8135='60'                     
8136='60'                     
8137='60'                     
8138='60'                     
8139='60'                     
8140='60'                     
8141='70'                     
8142='70'                     
8143='70'                     
8144='70'                     
8145='70'                     
8146='70'                     
8147='60'                     
8148='60'                     
8149='60'                     
815='50'                     
8150='60'                     
8151='70'                     
8152='60'                     
8153='60'                     
8154='60'                     
8155='60'                     
8156='60'                     
8157='60'                     
8158='60'                     
8159='60'                     
816='40' 
8160='70' 
8161='60'                     
8162='60'                     
8163='60'                     
8164='60'                     
8165='70'                     
8166='70'                     
8167='60'                     
8168='60'                     
8169='60'                     
8171='70'                     
8172='60'                     
8173='70'                     
8174='70'                     
8175='70'                     
8176='60'                     
8177='60'                     
8178='60'                     
8179='60'                     
8180='60'                     
8181='70'                     
8182='70'                     
8183='70'                     
8184='70'                     
8185='70'                     
8186='60'                     
8187='60'                     
8188='60'                     
8189='70'                     
8190='60'                     
8191='60'                     
8192='60'                     
8193='60'                     
8194='60'                     
8195='60'                     
8196='60'                     
8197='60'                     
820='30'                     
8200='70'                     
8201='70'                     
8202='70'                     
8203='70'                     
8204='70'                     
8205='70'                     
8206='70'                     
8207='70'                     
8208='70'                     
8209='70'                     
8210='70'                     
8211='70'                     
8212='70'                     
8213='70'                     
8214='70'                     
8215='70'                     
8216='70'                     
8217='70'                     
8218='70'                     
8219='70'                     
8220='70'                     
8221='70'                     
8222='70'                     
8223='70'                     
8224='70'                     
8225='70'                     
8226='70'                     
8227='70'                     
8228='70'                     
8229='70'   
8230='70'  
8231='70'                     
8232='70'                     
8233='70'                     
8234='70'                     
8235='70'                     
8236='70'                     
8237='70'                     
8238='70'                     
8239='70'                     
8240='70'                     
8241='70'                     
8242='70'                     
8243='70'                     
8244='70'                     
8245='70'                     
825='30'                     
8250='70'                     
8251='70'                     
8252='70'                     
8253='60'                     
8255='50'                     
8256='70'                     
8257='70'                     
8258='70'                     
8259='70'                     
8260='70'                     
8261='60'                     
8262='70'                     
8263='70'                     
8265='60'                     
8270='70'                     
8271='60'                     
8272='70'                     
8275='70'
8280='70'  
8281='70'                     
8282='60'                     
8283='70'                     
8284='70'                     
8285='60'                     
8290='60'                     
8291='60'                     
8292='60'                     
8295='70'                     
8296='70'                     
8300='70'                     
8301='80'                     
8302='70'                     
8303='70'                     
8304='70'                     
8305='70'                     
8306='70'                     
8307='70'                     
8308='70'                     
8309='70'                     
8310='70'                     
8311='70'                     
8312='70'                     
8313='70'                     
8314='70'                     
8315='70'                     
8316='70'                     
8317='70'                     
8318='70'                     
8319='70'                     
8320='70'                     
8321='70'                     
8322='70'                     
8323='70'                     
8324='70'                     
8325='70'                     
8326='70'                     
8327='70'                     
8328='70'                     
8329='70'                     
8330='70'                     
8331='70'                     
8332='70'                     
8333='70'                     
8334='70'                     
8335='70'                     
8336='70'                     
8337='70'                     
8338='70'                     
8339='70'                     
8340='70'                     
8341='70'                     
8342='70'                     
8343='70'                     
8344='70'                     
8345='70'                     
8346='70'                     
8347='70'                     
8348='70'                     
8349='70'                     
835='40'                     
8350='70'                     
8351='70'                     
8352='70'                     
8353='70'                     
8354='70'                     
8355='70'                     
8356='70'                     
8357='70'                     
8358='70'                     
8359='70'                     
8360='70'                     
8361='70'                     
8362='70'                     
8363='70'                     
8364='70'                     
8365='70'                     
8366='70'                     
8367='70'                     
8368='70'                     
8369='70'                     
8370='70'                     
8371='70'                     
8372='70'                     
8373='70'                     
8374='70'                     
8375='70'                     
8376='70'                     
8380='70'                     
8381='70'                     
8382='70'                     
8383='70'                     
8384='70'                     
8385='70'                     
8386='70'                     
840='50'                     
8400='60'                     
8401='40'                     
8402='60'                     
8403='60'                     
8404='60'                     
8405='60'                     
8406='60'                     
8407='60'                     
8408='40'                     
8409='60'                     
8410='60'                     
8411='60'                     
8412='60'                     
8413='40'                     
8415='70'                     
8416='70'                     
8420='60'                     
8440='50'                     
8441='40'                     
8442='40'                     
8443='40'                     
8444='40'                     
8445='50'                     
8446='50'                     
8447='50'                     
8448='50'                     
845='30'                     
850='30'                     
8501='50'                     
8502='50'                     
8503='50'                     
8504='50'                     
8505='50'                     
8506='50'                     
8507='50'                     
8508='50'                     
8510='50'                     
8511='50'                     
8518='50'                     
8519='50'                     
8520='50'                     
8521='50'                     
8522='50'                     
8523='40'                     
8524='50'                     
8525='50'                     
8526='50'                     
8552='50'                     
8553='50'                     
8554='50'                     
8555='50'                     
8556='50'                     
8557='50'                     
8558='50'                     
8559='50'                     
8560='50'                     
8561='50'                     
8562='50'                     
8563='50'                     
8585='70'                     
8586='50'                     
8599='50'                     
8600='50'                     
8601='50'                     
8602='50'                     
8603='50'                     
8604='40'                     
8620='50'                     
8621='50'                     
8622='50'                     
8623='50'                     
8624='50'                     
8625='50'                     
8626='50'                     
8627='50'                     
8628='50'                     
8629='50'                     
8630='50'                     
8631='50'                     
8632='50'                     
8633='50'                     
8634='50'                     
8635='50'                     
8636='50'                     
8637='50'                     
8638='50'                     
8639='50'                     
8655='50'                     
8656='50'                     
8657='50'                     
8658='50'                     
8670='50'                     
8671='50'                     
8672='50'                     
8673='50'                     
8674='50'                     
8750='70'                     
8800='70'                     
8801='70'                     
8802='70'                     
8803='70'                     
8804='70'                     
8805='70'                     
8806='70'                     
8807='70'                     
8808='70'                     
8809='70'                     
8810='70'                     
8811='70'                     
8812='70'                     
8813='70'                     
8814='70'                     
8815='70'                     
8816='70'                     
8817='70'                     
8818='70'                     
8819='70'                     
8820='70'                     
8821='70'                     
8822='70'                     
8823='70'                     
8824='70'                     
8825='70'                     
8826='70'                     
8827='70'                     
8828='70'                     
8829='70'                     
8830='70'                     
8831='70'                     
8832='70'                     
8833='70'                     
8834='70'                     
8835='70'                     
8836='70'                     
8837='70'                     
8838='70'                     
8839='70'                     
8840='70'                     
8841='70'                     
8842='70'                     
8843='70'                     
8844='70'                     
8845='70'                     
8846='70'                     
8847='70'                     
8848='70'                     
8849='70'                     
8850='70'                     
8851='70'                     
8852='70'                     
8853='70'                     
8854='70'                     
8855='70'                     
8856='70'                     
8857='70'                     
8858='70'                     
8859='70'                     
8860='70'                     
8861='70'                     
8862='70'                     
8863='70'                     
8864='70'                     
8865='70'                     
8866='70'                     
8867='70'                     
8868='70'                     
8869='70'                     
8870='70'                     
8871='70'                     
8872='70'                     
8873='70'                     
8874='70'                     
8875='70'                     
8876='70'                     
8877='70'                     
8878='70'                     
8879='70'                     
8880='70'                     
8881='70'                     
8882='70'                     
8883='70'                     
8884='70'                     
8885='70'                     
8886='70'                     
8887='70'                     
8888='70'                     
8889='70'                     
8890='70'                     
8891='70'                     
8892='70'                     
8893='70'                     
8894='70'                     
8895='70'                     
8896='70'                     
8897='70'                     
8898='70'                     
8899='70'                     
8900='70'                     
8901='70'                     
8902='70'                     
8903='70'                     
8904='70'                     
8905='70'                     
8906='70'                     
8907='70'                     
8908='70'                     
8909='70'                     
8910='70'                     
8911='70'                     
8912='70'                     
8913='70'                     
8914='70'                     
8915='70'                     
8916='70'                     
8917='70'                     
8918='70'                     
8919='70'                     
8920='70'                     
8921='70'                     
8922='70'                     
8923='70'                     
8924='70'                     
8925='70'                     
8926='70'                     
8927='70'                     
8928='70'                     
8929='70'                     
8930='70'                     
8931='70'                     
8932='70'                     
8933='70'                     
8934='70'                     
8935='70'                     
8936='70'                     
8937='70'                     
8938='70'                     
8939='70'                     
8940='70'                     
8941='70'                     
8942='70'                     
8943='70'                     
8944='70'                     
8945='70'                     
8946='70'                     
8947='70'                     
8948='70'                     
8949='70'                     
8950='70'                     
8951='70'                     
8952='70'                     
8953='70'                     
8954='70'                     
8955='70'                     
8956='70'                     
8957='70'                     
8958='70'                     
8959='70'                     
8969='70'                     
8970='70'                     
8971='70'                     
8972='70'                     
8973='70'                     
8974='70'                     
8975='70'                     
8976='70'                     
8977='70'                     
8978='70'                     
8979='70'                     
8980='70'                     
8994='70'                     
8995='70'                     
8996='70'                     
8997='70'                     
8998='70'                     
8999='70'                     
9014='20'                     
9015='50'                     
9020='50'                     
9030='50'                     
9034='70'                     
9035='70'                     
9036='70'                     
9037='70'                     
9038='70'                     
9039='70'                     
9040='70'                     
9041='70'                     
9042='70'                     
9043='70'                     
9044='70'                     
9045='70'                     
9046='70'                     
9047='70'                     
9049='70'                     
9050='70'                     
9051='70'                     
9052='70'                     
9053='70'                     
9054='70'                     
9055='70'                     
9056='70'                     
9057='70'                     
9061='70'                     
9062='70'                     
9106='30'                     
9121='70'                     
9122='70'                     
9123='70'                     
9124='70'                     
9125='70'                     
9132='40'                     
9144='40'                     
9167='50'                     
9171='80'                     
9172='50'                     
9173='30'                     
9174='70'                     
9175='70'                     
9176='50'                     
9197='50'                     
9203='40'                     
9215='30'                     
9224='50'                     
9225='70'                     
9258='80'                     
9264='70'                     
9266='80'                     
9267='80'                     
9269='80'                     
9315='39'                     
9316='39'                     
9317='39'                     
9320='39'                     
9321='39'                     
9322='39'                     
9327='39'                     
9328='39'                     
9329='39'                     
9330='30'                     
9332='39'                     
9333='39'                     
9334='39'                     
9338='39'                     
9339='70'                     
9342='30'                     
9369='30'                     
9382='30'                     
9384='30'                     
9385='70'                     
9386='30'                     
9390='80'                     
9391='70'                     
9392='70'                     
9393='70'                     
9394='70'                     
9395='70'                     
9396='70'                     
9397='70'                     
9398='70'                     
9399='70'                     
9400='70'                     
9403='70'                     
9404='70'                     
9405='70'                     
9406='70'                     
9407='70'                     
9409='70'                     
9410='70'                     
9412='70'                     
9413='70'                     
9414='70'                     
9416='70'                     
9418='70'                     
9420='70'                     
9422='70'                     
9423='70'                     
9424='70'                     
9429='30'                     
9430='80'                     
9431='30'                     
9434='30'                     
9435='30'                     
9440='30'                     
9445='30'                     
9450='80'                     
9465='70'                     
9467='30'                     
9468='30'                     
9469='70'                     
9470='50'                     
9471='70'                     
9472='70'                     
9473='70'                     
9474='50'                     
9475='70'                     
9476='70'                     
9477='50'                     
9481='70'                     
9483='39'                     
9484='30'                     
9485='30'                     
9486='30'                     
9487='70'                     
9488='80'                     
9490='70'                     
9491='70'                     
9492='80'                     
9493='70'                     
9495='50'                     
9498='70'                     
9500='70'                     
9502='80'                     
9504='70'                     
9505='70'                     
9508='70'                     
9514='70'                     
9515='70'                     
9517='39'                     
9518='80'                     
9529='40'                     
9531='50'                     
9533='40'                     
9534='40'                     
9535='40'                     
9536='40'                     
9537='40'                     
9538='40'                     
9539='40'                     
9540='30'                     
9541='40'                     
9542='40'                     
9556='80'                     
9564='30'                     
9569='30'                     
9571='80'                     
9572='50'                     
9573='30'                     
9574='50'                     
9580='50'                     
9584='50'                     
9585='50'                     
9586='50'                     
9588='50'                     
9589='50'                     
9602='10'                     
9603='10'                     
9604='10'                     
9606='10'                     
9607='10'                     
9618='40'                     
9620='50'                     
9621='30'                     
9622='30'                     
9623='30'                     
9636='30'                     
9654='30'                     
9655='50'                     
9658='50'                     
9661='35'                     
9668='70'                     
9677='39'                     
9678='39'                     
9679='39'                     
9681='39'                     
9682='39'                     
9683='39'                     
9684='39'                     
9685='39'                     
9686='70'                     
9687='50'                     
9688='50'                     
9689='39'                     
9693='39'                     
9694='39'                     
9695='39'                     
9696='39'                     
9697='39'                     
9698='39'                     
9699='39'                     
9703='39'                     
9704='39'                     
9705='50'                     
9706='39'                     
9707='50'                     
9708='39'                     
9709='39'                     
9710='39'                     
9711='39'                     
9712='39'                     
9713='39'                     
9714='50'                     
9715='39'                     
9716='70'                     
9717='70'                     
9718='39'                     
9719='39'                     
9720='30'                     
9721='30'                     
9722='30'                     
9723='39'                     
9724='39'                     
9725='39'                     
9726='39'                     
9730='39'                     
9731='39'                     
9732='39'                     
9733='39'                     
9734='39'                     
9735='39'                     
9736='39'                     
9737='39'                     
9738='39'                     
9739='39'                     
9740='39'                     
9741='39'                     
9742='39'                     
9743='39'                     
9744='39'                     
9745='39'                     
9746='39'                     
9747='39'                     
9748='39'                     
9749='39'                     
9750='39'                     
9751='39'                     
9752='39'                     
9753='39'                     
9754='39'                     
9755='39'                     
9756='39'                     
9757='39'                     
9758='39'                     
9759='39'                     
9760='39'                     
9761='39'                     
9762='39'                     
9763='39'                     
9764='39'                     
9765='39'                     
9766='39'                     
9767='39'                     
9768='39'                     
9769='39'                     
9770='39'                     
9771='39'                     
9772='39'                     
9773='39'                     
9774='39'                     
9775='39'                     
9776='39'                     
9777='39'                     
9778='39'                     
9779='39'                     
9780='39'                     
9781='39'                     
9782='39'                     
9783='39'                     
9784='39'                     
9785='39'                     
9786='39'                     
9787='39'                     
9788='39'                     
9800='39'                     
9801='39'                     
9802='39'                     
9803='39'                     
9804='39'                     
9805='39'                     
9806='39'                     
9807='39'                     
9808='39'                     
9809='39'                     
9810='39'                     
9811='39'                     
9812='39'                     
9813='39'                     
9814='39'                     
9815='39'                     
9816='39'                     
9817='39'                     
9818='39'                     
9819='39'                     
9820='39'                     
9821='39'                     
9822='39'                     
9823='39'                     
9824='39'                     
9825='39'                     
9826='39'                     
9827='39'                     
9828='39'                     
9829='39'                     
9830='39'                     
9831='39'                     
9832='39'                     
9833='39'                     
9834='39'                     
9835='39'                     
9836='39'                     
9837='39'                     
9838='39'                     
9839='39'                     
9840='39'                     
9841='39'                     
9842='39'                     
9843='39'                     
9844='39'                     
9845='39'                     
9846='39'                     
9847='39'                     
9848='39'                     
9849='39'                     
9850='39'                     
9851='39'                     
9852='39'                     
9853='39'                     
9854='39'                     
9855='39'                     
9856='39'                     
9857='39'                     
9858='39'                     
9859='39'                     
9860='39'                     
9861='39'                     
9862='39'                     
9863='39'                     
9864='39'                     
9865='39'                     
9866='39'                     
9867='39'                     
9868='39'                     
9869='39'                     
9870='39'                     
9871='39'                     
9872='39'                     
9873='39'                     
9874='39'                     
9875='39'                     
9876='39'                     
9877='39'                     
9878='39'                     
9879='39'                     
9880='39'                     
9881='39'                     
9882='39'                     
9883='39'                     
9884='39'                     
9886='39'                     
9887='39'                     
9888='39'                     
9889='39'                     
990='70'                     
9909='30'                     
9910='30'                     
9911='30'                     
9912='30'                     
9913='30'                     
9914='30'                     
9915='30'                     
9916='30'                     
9917='30'                     
9918='30'                     
9933='30'                     
9999='90'                     
;
run;

proc format;
	value educ	
					10		= 	"Basic school"
					17		= 	"Basic school"
					20		=	"General upper secondary"
					25		=	"Vocational upper secondary"
					30		=	"Vocational education and training"
					35		=	"Vocational education and training"
					39		=	"Vocational education and training"
					40		=	"Short higher education"
					50		=	"Medium higher education"
					60		=	"Bachelor degree"
					65		=	"Long higher education"
					70		=	"Master degree"
					80		=	"PhD"
					90		=	"Missing";
run;


*-----------------------------------------------------------------------------------------------------------;
*	2) LOAD INPUTDATA;
*-----------------------------------------------------------------------------------------------------------;


*IMPORT CONSUMER PRICE INDEX (PRIS112 FROM STATISTIKBANKEN.DK);
proc import out=work.cpi
datafile="&input.\CPI.csv" 
dbms=csv replace; delimiter=';'; getnames=yes; run;



*IMPORT LOCAL UNEMPLOYMENT RATES BY MUNICIPALITIES, 1996 (AARD FROM STATISTIKBANKEN.DK);
proc import out=work.unemp_mun
datafile="&input.\AARD.csv" 
dbms=csv replace; delimiter=';'; getnames=yes; run;


proc sort DATA=UNEMP_MUN; by kom; run;


data unemp_mun (keep=municipality_org urate1996);
set unemp_mun;
if kom ne .; 
rename kom=municipality_org;
urate1996=urate1996/100;
label urate1996="Unemployment Rate in Municipality 1996";
run;


**********************************************************;
*IMPORT DANISH TRAINING DATA (DKDB 1999-2003);
**********************************************************;

proc import out=work.dkdb (rename=year=year_dkdb)
datafile="&dkdb.\dkdb1999_2003" 
dbms=dta replace; run;



**********************************************************;
* IMPORT POPULATION OF REFUGEES;
**********************************************************;

proc import out=work._refugees (drop= indv_land grundlag kategori datdif--ie_type statsb--first_bopikom_source ref2)
datafile="&input.\Refugees1997_" 
dbms=dta replace; run;


*-----------------------------------------------------------------------------------------------------------;


*************************************************************************************************************************************************;
* IMPORT BEF-DATA TO GET FAMILY-ID FOR THE FULL POPULATION TO MATCH TO NUMBER OF CHILDREN AND DEFINE ORIGIN COUNRY, MARITAL STATUS AND GENDER   *;
*************************************************************************************************************************************************;

data bef (drop=pnr_n _civst);
set raw.befupdv (
where=(year_p >=1996)
keep=pnr familie_id opr_land kom civst foed_dag befupdsourceyear
rename=(pnr=pnr_n befupdSourceYear=year_p civst=_civst)
);
pnr=pnr_n*1;
if pnr ne .;

if _civst eq 'U' or _civst eq 'u'  then civst=1;
	else if _civst eq 'F' or _civst eq 'f'  then civst=2;
	else if _civst eq 'O' or _civst eq 'o'  then civst=3;
	else if _civst eq 'E' or _civst eq 'e'  then civst=4;
	else if _civst eq 'L' or _civst eq 'l'  then civst=5;
	else if _civst eq 'D' or _civst eq 'd'  then civst=9;
	else if _civst eq 'G' or _civst eq 'g'  then civst=11;
	else if _civst eq 'A' or _civst eq 'a'  then civst=12;
	else if _civst eq 'S' or _civst eq 's'  then civst=13;
	else if _civst eq 'X' or _civst eq 'x'  then civst=14;
	else if _civst eq 'P' or _civst eq 'p'  then civst=15;
	else civst= . ;

run;


**********************************************************************************************************;
*	IMPORT CHILDREN FROM BEF TO COUNT NUMBER OF SMALL CHILDREN BY FAMILY AND YEAR (UNDER 18 YEARS OF AGE) *;
**********************************************************************************************************;

data _kids ;
set bef (
where=(year_p >=1997)
keep=pnr familie_id foed_dag year_p);
_date=mdy(01,01,year_p);
format _date ddmmyy.;
if foed_dag ne . then age=int(yrdif(foed_dag,_date,age));
if age < 18;
child=1;
run;


data _kids2; set _kids; if age <= 2; run;
data _kids18; set _kids; if age > 2 and age < 18; run;


*SUM NUMBER OF CHILDREN UNDER 3Y, 3-17Y BY FAMILY ID AND YEAR;
%macro kids;
%do c=2 %to 18 %by 16;
proc sort data=_kids&c.; by familie_id year_p; run;
proc means data=_kids&c. noprint; by familie_id year_p; var child; 
output out=_kids&c. (drop= _freq_ _type_) sum(child)=kids0&c.; run;
%end;
%mend;
%kids;


*MERGE DATA ON CHILDREN;
data fam;
merge _kids2 _kids18;
by familie_id year_p;
label kids02="Children Younger Than 3y" kids018="Children 3-17y";
if familie_id ne "      .";
run;




*****************************************************************;
* 		IMPORT IDAP DATA: CALCULATE LABOR MARKET EXPERIENCE		*;
*****************************************************************;

*1995-2007;
data _ida1 (drop=pnr_n erhver erhver79);
set raw.idapv  (
where=(idapSourceYear >=1995 and idapSourceYear<=2007)
keep=pnr erhver erhver79 idapSourceYear
rename=(pnr=pnr_n)
);
rename idapsourceyear=year_p;
pnr=pnr_n*1;
if pnr ne .;

if erhver ne . then erhver=erhver/1000;
if erhver ne . | erhver79 ne . then exper=sum(erhver,erhver79);
label exper="Labor Market Experience (Years)";
run;

*2008-2016;
data _ida2 (drop=pnr_n erhver erhver79);
set raw.idapupdv  (
where=(idapupdSourceYear >=2008)
keep=pnr erhver erhver79 idapupdSourceYear
rename=(pnr=pnr_n)
);
rename idapupdsourceyear=year_p;
pnr=pnr_n*1;
if pnr ne .;

if erhver ne . then erhver=erhver/1000;
if erhver ne . | erhver79 ne . then exper=sum(erhver,erhver79);
label exper="Labor Market Experience (Years)";
run;

data ida (keep=pnr year_p exper);
set _ida1 _ida2;
run;



*************************************************************************************;
*								IMPORT TIME CONSISTENT ISCO88-CODES (4 DIGIT)		*;
*************************************************************************************;

data idanakm;
set in.idanakm;
keep pnr isco88 year lbnr;
rename isco88=isco4d year=year_p;
run;

*************************************************;
*		IMPORT INCOME DATA 						*;
*************************************************;

data _ind (drop=pnr_n);
set raw.indupd01v (
where=(indupd01SourceYear>=1996)
keep=pnr loenmv_13 andbistandyd intgrayd khflygt konthj dispon_13 indupd01SourceYear
rename=(pnr=pnr_n)
);
rename indupd01SourceYear=year_p;
pnr=pnr_n*1;
if pnr ne .;
run;

proc sort data=_ind; by year_p; run;


*DEFLATE INCOME AND CONVERT TO 1000 DOLLARS;
data ind;
merge _ind (in=a) cpi;
by year_p;
if a;
%macro cpi(var=);
&var.=&var./cpi*100/&dollar./&thousand.;
%mend;
%cpi(var=andbistandyd);
%cpi(var=khflygt);
%cpi(var=konthj);
%cpi(var=loenmv_13);
%cpi(var=intgrayd);
%cpi(var=dispon_13);

%macro m(var=);
if &var.=. then &var.=0;
%mend;
%m(var=konthj);
%m(var=khflygt);
%m(var=andbistandyd);
%m(var=intgrayd);

UA_sum=konthj+khflygt+andbistandyd+intgrayd;
label 	UA_sum="Welfare Benefits" loenmv_13="Gross Earnings" dispon_13="Disposable Income";

drop cpi konthj khflygt andbistandyd intgrayd;
run;


*************************************************;
*	IMPORT AMFORA DATA TO FIND HOURS IN ALMP	*;
*************************************************;

data AMFO (drop=pnr_n);
set raw.AMFOv
(where=(amfosourceyear >= 1997)
keep=pnr foranst slutdto startdto timerpu ydtype1 stedtype amfosourceyear 
rename=pnr=pnr_n);
in_amfo=1;
pnr=pnr_n*1;
if pnr ne .;
rename amfosourceyear=year_p;
format timerpu comma10.0;
run;

proc sort data=amfo nodup; by pnr; run;


*********************************************************************************************;
*		IMPORT ADULT EDUCATION DATA TO DETERMINE DANISH LANGUAGE TRACK PLACEMENT 			*;
*********************************************************************************************;

data veuv;
set raw.veuvv (drop= veuvSourceYear keep=pnr kursist_vtil kursist_vfra udd);
if year(kursist_vtil) >1996;
p=input(pnr,12.);
drop pnr;
rename p=pnr;
year_p=year(kursist_vfra);
run;



*************************************************************;
*	IMPORT CRIME DATA TO STUDY CONVICTIONS AND  CHARGES		*;
*************************************************************;

*COURT RULINGS;
*DROP CASES THAT DID NOT LEAD TO CONVICTIONS;
data _kraf 		(drop=pnr_n);
set raw.krafv 	(rename=(pnr=pnr_n afg_ger7=kraf_ger7));
rename krafsourceyear	=	year_p;
pnr		=	pnr_n+0;
if pnr ne .;
krsi=.;
if afg_afgtyp3=413 or afg_afgtyp3=514 or afg_afgtyp3=519 then delete;
if afg_afgtyp3=414 or afg_afgtyp3=0 or afg_afgtyp3=550 or afg_afgtyp3=551 or afg_afgtyp3=555 or afg_afgtyp3=556 then delete;
run;

*CHARGES;
data _krsi 		(drop=pnr_n);
set raw.krsiv 	(rename=(pnr=pnr_n sig_ger7=krsi_ger7));
rename krsisourceyear	=	year_p;
pnr		=	pnr_n+0;
if pnr ne .;
kraf=.;
run;

*SORT DATA;
proc sort data=_krsi;	by pnr year_p; run;
proc sort data=_kraf;	by pnr year_p; run;




*************************************************************************************************;
*	 IMPORT UDDA DATA TO STUDY FORMAL EDUCATION IN DENMARK									 	*;
*************************************************************************************************;

data _udda (drop=pnr_n);
set raw.uddaupd01v (rename=pnr=pnr_n);
pnr=pnr_n*1;
if pnr ne .;
h=put(hfaudd,UDD_HOVED_L1L5_K.)*1;
if hf_kilde ne .;
rename uddaupd01sourceyear=year;
format h educ. ;
run;




*-----------------------------------------------------------------------------------------------------------;
*	3) GENERATE VARIABLES;
*-----------------------------------------------------------------------------------------------------------;

*********************************************************;
*	ASYLUM APPLICATION DATA FOR ADMISSIONS 1997-2019	*;
*********************************************************;

*APPLICATION DATE BEFORE 2019;
data application2018 (drop=_pnr);
	set us.OPHOLDSTILLADELSE_ASYL_1997_2018 (rename=(pnr=_pnr 'ansøgningsdato/indrejsedato'n =application));
	pnr=_pnr*1;

	if pnr ne .;
	format application ddmmyy. tilladelsesdato ddmmyy.;
	year_application=year(application);
run;


*ASYLUM APPLICATION DATA 2019;
data application2019 (drop=_pnr);
	set us.OPHOLDSTILLADELSE_ASYL_2019 (rename=(pnr=_pnr 'indrejsedato/asylansøgningsdato'n =_application));
	pnr=_pnr*1;

	if pnr ne .;
	application=input(_application,yymmdd10.);
	format application ddmmyy. tilladelsesdato ddmmyy.;
	year_application=year(application);
	drop _application;
run;

*COMBINE APPLICATION DATA;
data application;
	retain pnr application;
	keep pnr application year_application;
	set application2018 application2019;
	label year_application="Year of Asylum Application" application="Application date/date of arrival";
run;

*SORT DATA BY PERSON-ID AND APPLICATION YEAR;
proc sort data=application; by pnr application; run;
proc sort data=application nodupkey; by pnr; run;



proc sort data=_refugees; by pnr; run; 

*ADD APPLICATION DATE FOR REFUGEES;
data _refugees;
merge _refugees (in=a) application;
by pnr;
if a;

if ref_type=1 then waittime=tilladelsesdato-application;
if ref_type ne 1 then do;
application=.;
year_application=.;
end;
female=koen-1;
label female="Female" waittime="Wait Time Asylum (Days)";
drop koen;
run;





*************************************************************;
*	DEFINE CONVICTIONS AND  CHARGES		*;
*************************************************************;

*KEEP CHARGES AND RULINGS ACCORDING TO THE CRIMINAL CODE;
%macro data(dataset=);
data &dataset.(keep	= pnr year_p property_sm &dataset. kraf krsi);
set _&dataset.;
&dataset.	=	1;
if substrn(&dataset._ger7,1,1)	=	1	or substrn(&dataset._ger7,1,2)	=	32 or substrn(&dataset._ger7,1,2)	=	34;

%macro types(crime_spec=);
if substrn(&dataset._ger7,1,7)	=	&&&crime_spec.	 then do;
&crime_spec.			=	1;
label &crime_spec.	=	"&crime_spec. crime";
end;
%mend;
%types(crime_spec=property_sm);

run;
%mend;
%data(dataset=krsi);
%data(dataset=kraf);


*SPLIT DATASET BY YEAR;
%macro c(data=);
%macro crime(crime=);
data &data._&crime.1 &data._&crime.2 &data._&crime.3 &data._&crime.4 &data._&crime.5 &data._&crime.6 &data._&crime.7 &data._&crime.8 &data._&crime.9 &data._&crime.10 
&data._&crime.11 &data._&crime.12 &data._&crime.13 &data._&crime.14 &data._&crime.15 &data._&crime.16 &data._&crime.17 &data._&crime.18 &data._&crime.19 _other;
set &data. (where=(&crime.=1) keep=pnr &crime. year_p);
select(year_p);
when(1999) output &data._&crime.1; when(2000) output &data._&crime.2; when(2001) output &data._&crime.3; when(2002) output &data._&crime.4; when(2003) output &data._&crime.5;
when(2004) output &data._&crime.6; when(2005) output &data._&crime.7; when(2006) output &data._&crime.8; when(2007) output &data._&crime.9;
when(2008) output &data._&crime.10; when(2009) output &data._&crime.11; when(2010) output &data._&crime.12; when(2011) output &data._&crime.13; when(2012) output &data._&crime.14;
when(2013) output &data._&crime.15; when(2014) output &data._&crime.16; when(2015) output &data._&crime.17; when(2016) output &data._&crime.18; 
otherwise output _other;
end;
run;
%mend;
%crime(crime=kraf);
%crime(crime=krsi);
%crime(crime=property_sm);
%mend;
%c(data=kraf);
%c(data=krsi);


*DELETE MEANINGLESS DATASETS;
proc datasets nolist; delete kraf_krsi: krsi_kraf:; run;


*DELETE DUPLICATES;
%macro dat(data=);
%macro crim(crime=);
%macro ye;
%do year=1 %to 18;
proc sort data=&data._&crime.&year. nodupkey out=_&data._&crime.&year. (rename=&crime.=&crime._&data.&year. drop=year_p); by pnr; run;
%end;
%mend;
%ye;
%mend;
%crim(crime=property_sm);
%mend;
%dat(data=kraf);
%dat(data=krsi);

%macro ye;
%do year=1 %to 18;
proc sort data=kraf_kraf&year. nodupkey out=_kraf_kraf&year. (rename=kraf=convicted&year. drop=year_p); by pnr; run;
proc sort data=krsi_krsi&year. nodupkey out=_krsi_krsi&year. (rename=krsi=charged&year. drop=year_p); by pnr; run;
%end;
%mend;
%ye;


proc sort data=_refugees; by pnr; run;

*MERGE AND SET MISSINGS TO ZERO;
data crimes (keep=pnr convicted1-convicted18 charged1 charged2 property_sm_kraf1 property_sm_kraf2 property_sm_krsi1 property_sm_krsi2);
merge _refugees (in=a keep=pnr) _kraf_kraf1-_kraf_kraf18 _krsi_krsi1-_krsi_krsi18 
_kraf_property_sm1-_kraf_property_sm18 
_krsi_property_sm1-_krsi_property_sm18;
if a;
by pnr;
%macro ye;
%do year=1 %to 18;
%macro dat(data=);
%macro crim(crime=);
if &crime._&data.&year.		=. then &crime._&data.&year.=0;
%mend;
%crim(crime=property_sm);
%mend;
%dat(data=kraf);
%dat(data=krsi);
if convicted&year.		=. then convicted&year.		=0;
if charged&year.		=. then charged&year.		=0;
%end;
%mend;
%ye;
run;




***************************************************;
*	DEFINE EDUCATIONAL OUTCOMES;
***************************************************;


*SPLIT EDUCATION DATA BY YEAR AND DROP IF DANISH LANGUAGE TRAINING. KEEP EDUCATION OBTAINED IN DENMARK;
data _udda1 _udda2 _udda3 _udda4 _udda5 _udda6 _udda7 _udda8 _udda9 _udda10 _udda11 _udda12 _udda13 _udda14 _udda15 _udda16 _udda17 _udda18 _other;
set _udda (where=(year>1998 and (hfaudd <1301 or hfaudd >1305) and hf_kilde in &educ_dk.) keep=pnr hf_kilde hfaudd h year );
select(year);
when(1999) output _udda1; when(2000) output _udda2; when(2001) output _udda3; when(2002) output _udda4; when(2003) output _udda5; when(2004) output _udda6; when(2005) output _udda7; when(2006) output _udda8; when(2007) output _udda9;
when(2008) output _udda10; when(2009) output _udda11; when(2010) output _udda12; when(2011) output _udda13; when(2012) output _udda14; when(2013) output _udda15; 
when(2014) output _udda16; when(2015) output _udda17; when(2016) output _udda18; 
otherwise output _other;
end;
run;


*RENAME VARIABLES AND SORT AND DELETE DUPLICATES;
%macro udda;
%do k=1999 %to 2016;

data udda%eval(&k.-1998);
set _udda%eval(&k.-1998);
rename hf_kilde=hf_kilde%eval(&k.-1998) h=h%eval(&k.-1998) hfaudd=hfaudd%eval(&k.-1998);
drop year;
run;

proc sort data=udda%eval(&k.-1998); by pnr hf_kilde%eval(&k.-1998); run;
proc sort data=udda%eval(&k.-1998) nodupkey; by pnr; run;
%end;
%mend;
%udda;





***********************************************************************;
*		 MERGE DATA ON CHILDREN TO ADULTS				 		  	  *;
***********************************************************************;

proc sort data=fam; by familie_id year_p; run;
proc sort data=bef nodup; by familie_id year_p; run;

*MERGE NUMBER OF CHILDREN TO ADULTS BY FAMILY ID;
data bef2; set bef (where=(year_p>=1997)); drop opr_land kom koen female civst; run;

proc sql noprint;
create table children as select * from fam a
join bef2 b
on a.familie_id =b.familie_id and a.year_p =b.year_p;
quit;



*SORT AND DELETE DUPLICATES;
proc sort data=bef nodupkey; by pnr year_p; run;
proc sort data=ida nodupkey; by pnr year_p; run;
proc sort data=ind nodupkey; by pnr year_p; run;
proc sort data=children nodupkey; by pnr year_p; run;
proc sort data=idanakm nodupkey; by pnr year_p; run;


*MERGE  IDA, BEF, AKM AND IND BY PERSON AND YEAR;
data persons;
retain pnr year_p;
merge bef (in=a where=(year_p>=1995)) ida ind (where=(year_p>=1997)) 
children idanakm;
by pnr year_p;
if kids02=. then kids02=0;
if kids018=. then kids018=0;
if lbnr ne " " then employment_nov=1; else employment_nov=0;
label employment_nov="Employed in November";
drop lbnr;
run;


*SORT AND CHECK FOR DUPLICATES;
proc sort data=persons nodupkey; by pnr year_p; run;


*CALCULATE EMPLOYMENT AS FIRST DIFFERENCES IN LABOR MARKET EXPERIENCE.;
data persons2;
set persons;
by pnr;
exper_lag=lag(exper);
year_p_lag=lag(year_p);
pnr_lag=lag(pnr);

*USE FIRST YEAR OF RECORDED LABOR MARKET EXPERIENCE AS EMPLOYMENT RATE IN FIRST YEAR;
if first.pnr then do;
emp=exper;
exper_lag=.;
end;

if pnr=pnr_lag and year_p=year_p_lag+1 then do;
emp=(exper-exper_lag);
end;

drop exper_lag pnr_lag year_p_lag;
if emp < 0 then emp=0;
if emp >1 then emp=1;
if emp = . then emp=0;
label emp="Annual Rate of Employment (FD Labor Market Experience)";
run;



***************************************************************;
* CREATE INDEX FOR CO-NATIONALS IN MUNICIPALITY BY YEAR 	  *;
***************************************************************;

*SORT AND DELETE DUPLICATES AND MISSINGS;
proc sort data=bef nodupkey out=conat; by pnr year_p; run;
proc sort data=conat; by kom year_p opr_land; run;

data conat (drop=kom); 
set conat; 
if pnr ne . and kom ne .; 
municipality_org=kom*1;
dummy=1;
run;

*TOTAL POPULATION IN MUNICIPALITY BY YEAR;
proc means data=conat noprint; by municipality_org year_p; var dummy;
output out=conationals_tot (drop=_type_ _freq_ rename=year_p=year)
sum(dummy)=pop_total; run;

*POPULATION IN MUNICIPALITY BY YEAR AND ORIGIN COUNTRY;
proc means data=conat noprint; by municipality_org year_p opr_land; var dummy;
output out=conationals (drop=_type_ _freq_ rename=year_p=year) sum(dummy)=n_conationals; run;



***********************************************************************;
*	CALCULATE AVERAGE INCOME IN MUNICIPALITY IN 1996
***********************************************************************;

proc sort data=ind; by pnr year_p; run;

data _municipalityincome;
merge bef (in=a where=(year_p=1996)) ind (where=(year_p=1996));
by pnr year_p;
if a;
municipality_org=kom*1;
run;

*AVERAGE INCOME IN MUNICIPALITY FOR THOSE WHO HAVE POSITIVE INCOME;
proc means data=_municipalityincome (where=(year_p=1996 and loenmv_13 >0)) noprint;
class municipality_org; var loenmv_13;
output out=_mu_loenmv_131996 (drop= _type_ _freq_ where=(municipality_org ne .)) mean(loenmv_13)=avg_loenmv_131996;
run;


***********************************************************************;
*	CALCULATE EMPLOYMENT RATES IN MUNICIPALITY IN 1996
***********************************************************************;

data _municipalityemployment;
set persons2 (where=(year_p=1996) keep=pnr foed_dag year_p emp kom);
municipality_org=kom*1;
employment=0;
if emp>0 then employment=1;
age=year_p-year(foed_dag);
if age>=20 and age<=64;
run;

*AVERAGE EMPLOYMENT RATE IN MUNICIPALITY;
proc means data=_municipalityemployment (where=(year_p=1996)) noprint;
class municipality_org; var employment;
output out=_mu_emprate1996 (drop= _type_ _freq_ where=(municipality_org ne .)) mean(employment)=emprate1996;
run;


*************************************************************************************************************************;
*	MERGE POPULATION TO LOCAL UNEMPLOYMENT AND EMPLOYMENT RATES AND AVERAGE INCOME IN MUNICIPALITIES, 1996	 	*;
*************************************************************************************************************************;

*CONVERT NEW MUNICIPALITY CODES TO OLD FOR TIME CONSISTENCY;
data refugees;
set _refugees;
if municipality_org=580 then municipality_org=545;
if municipality_org=420 then municipality_org=421; 
if municipality_org=530 then municipality_org=551; 
if municipality_org=810 then municipality_org=805; 
if municipality_org=250 then municipality_org=209; 
if municipality_org=510 then municipality_org=515; 
if municipality_org=766 then municipality_org=613;
if municipality_org=860 then municipality_org=821; 
if municipality_org=316 then municipality_org=315; 
if municipality_org=326 then municipality_org=323;  
if municipality_org=440 then municipality_org=439; 
if municipality_org=350 then municipality_org=261; 
if municipality_org=410 then municipality_org=445; 
if municipality_org=450 then municipality_org=449; 
if municipality_org=370 then municipality_org=373; 
if municipality_org=730 then municipality_org=731; 
if municipality_org=740 then municipality_org=743; 
if municipality_org=746 then municipality_org=745; 
if municipality_org=330 then municipality_org=333; 
if municipality_org=336 then municipality_org=389; 
if municipality_org=540 then municipality_org=537; 
if municipality_org=550 then municipality_org=541; 
if municipality_org=630 then municipality_org=631; 
if municipality_org=390 then municipality_org=397;
if municipality_org=190 then municipality_org=189; 
if municipality_org=210 then municipality_org=208;
if municipality_org=230 then municipality_org=205;
if municipality_org=240 then municipality_org=237;
if municipality_org=260 then municipality_org=211;
if municipality_org=270 then municipality_org=213;
if municipality_org=306 then municipality_org=327;
if municipality_org=320 then municipality_org=351;
if municipality_org=360 then municipality_org=367;
if municipality_org=376 then municipality_org=369;
if municipality_org=430 then municipality_org=431;
if municipality_org=480 then municipality_org=471;
if municipality_org=482 then municipality_org=475;
if municipality_org=492 then municipality_org=443; 
if municipality_org=706 then municipality_org=701;
if municipality_org=710 then municipality_org=709;
if municipality_org=756 then municipality_org=663;
if municipality_org=760 then municipality_org=667;
if municipality_org=820 then municipality_org=861;
if municipality_org=840 then municipality_org=845;
if municipality_org=846 then municipality_org=823;
run;

proc sort data=refugees; by municipality_org; run;
proc sort data=unemp_mun; by municipality_org; run;


*MERGE LOCAL UNEMPLOYMENT AND EMPLOYMENT RATES AND AVERAGE INCOME TO REFUGEE POPULATION DATA;
DATA refugees;
merge refugees (in=a) unemp_mun _mu_emprate1996 unemp_mun _mu_loenmv_131996;
by municipality_org;
if a;
if emprate1996=. then emprate1996=0;
if urate1996=. then urate1996=0;
if avg_loenmv_131996=. then avg_loenmv_131996=0;
label avg_loenmv_131996="Average Income in Municipality 1996" emprate1996="Employment Rate 1996 (Out of Population 20-64)";
run;


*****************************************************************;
*	 ADD INDEX FOR CO-NATIONALS IN MUNICIPALITY BY YEAR 		*;
*****************************************************************;

proc sort data=refugees; by municipality_org year opr_land; run;

*MERGE CO-NATIONALS NUMBER TO POPULATION OF REFUGEES;
data refugees;
merge refugees (in=a) conationals;
by municipality_org year opr_land;
if a;
label n_conationals="Number of Conationals in Municipality" ;
run;

*MERGE TOTAL NUMBER IN MUNICIPALITY-POPULATION TO REFUGEE POPULATION;
data refugees;
merge refugees (in=a) conationals_tot;
by municipality_org year;
if a;
if n_conationals ne . then s_conationals=n_conationals/pop_total;
if n_conationals=. then s_conationals=0;
if municipality_org=. then s_conationals=.;
if municipality_org ne . and n_conationals=. then n_conationals=0;
label s_conationals="Share of Conationals in Municipality";
drop pop_total;
run;

proc sort data=refugees; by pnr; run;



******************************************************************;
* 			CUMULATIVE HOURS IN ALMP (AMFORA)					 *;
******************************************************************;


proc sort data=refugees; by pnr; run;

*CALCULATE HOURS IN ALMP THE FIRST 12, 18, 24, 30, 36 MONTHS;
%macro m(months=);
data almp_&months.f;
merge amfo (in=a) refugees (in=b keep=pnr dato tilladelsesdato);
by pnr;
if b;
dato3=intnx("month",dato,&months.,'same');
weeks=intck('week',max(startdto,dato),min(slutdto,dato3),'C');
format dato3 ddmmyy10. dato ddmmyy10. tilladelsesdato ddmmyy10.;
if slutdto < dato or startdto > dato3 then delete;
if foranst in &soc. or foranst in &language. then intser=1;
if foranst not in &soc. and foranst not in &language. then emplser=1;
total_hours=weeks*timerpu;
label total_hours="Cumulative Hours First &months. After Immigration (AMFORA)";
run;
%mend;
%m(months=12);
%m(months=18);
%m(months=24);
%m(months=30);
%m(months=36);



*  SUM TOTAL CUMULATIVE HOURS IN EMPLOYMENT OR INTEGRATION SERVICES; 
%macro almp(t=);
*DELETE DUPLICATES;
proc sort data=almp&t.f nodup;
by pnr descending weeks startdto descending slutdto foranst timerpu stedtype ydtype1;
run;

*DROP IF MULTIPLE RECORDS OF THE SAME ALMP SPELL;
data almp2&t.f;
set almp&t.f;
by pnr;
if first.pnr then keep=1;
if pnr=lag(pnr) and foranst=lag(foranst) and stedtype=lag(stedtype) and ydtype1=lag(ydtype1) and startdto<=lag(startdto) then keep=0;
if keep=0 then delete;
drop keep;
run;



%macro type(type=);
proc sort data=almp2&t.f; by pnr &type.; run;
proc means data=almp2&t.f noprint;
by pnr &type.;
var total_hours;
output out=almp_&type.&t.f (drop= _type_ _freq_) sum(total_hours)=hours_&type.&t.;
run;

data almp_&type.&t.f;
set almp_&type.&t.f;
if &type. ne 1 then delete;
rename &type.=&type.&t._d;
label hours_&type.&t.="Cumulative Hours in &type. &t. Months";
run;

%mend;
%type(type=intser);
%type(type=emplser);

%mend;
%almp(t=_12);
%almp(t=_18);
%almp(t=_24);
%almp(t=_30);
%almp(t=_36);




**************************************************************************************************;
*			  FIRST PLACEMENT IN DANISH LANGUAGE TRAINING TRACK									 *;
**************************************************************************************************;

proc sort data=veuv; by pnr; run;
proc sort data=refugees; by pnr; run;


*KEEP LANGUAGE TRAINING SPELLS THAT WERE INITIATED AFTER ENTRY AND BEFORE THE 3-YEAR INTEGRATION PERIOD ENDED;
data veuv2;
merge veuv refugees (in=a keep=pnr dato tilladelsesdato) ;
by pnr;
if a;
dato3=intnx("year",dato,3,'same');
format dato3 ddmmyy10. dato ddmmyy10. tilladelsesdato ddmmyy10.;
if kursist_vtil < dato or kursist_vfra > dato3 then delete;
if udd=1301 or udd=1302 or udd=1303 or udd=1305;
run;


proc sort data=veuv2; by pnr year_p udd; run;

*FIRST KNOWN LANGUAGE TRACK PLACEMENT;
data veuv_first (keep=pnr level_first);
set veuv2 (where= (udd ne 1305));
by pnr;
if first.pnr;
if udd=1301 then level_first=1;
if udd=1302 then level_first=2;
if udd=1303 then level_first=3;
label level_first="Danish Level (First Placement)";
run;

proc sort data=veuv_first nodupkey; by pnr; run;



*MERGE INITIAL LANGUAGE TRACK PLACEMENTS TO POPULATION DATA;
data refugees;
merge refugees (in=a) veuv_first;
by pnr;
if a;
run;


*************************************************;
*		 MERGE TO LANGUAGE TRAINING DATA (DKDB) *;
*************************************************;
proc sort data=refugees; by pnr; run;
proc sort data=dkdb; by pnr year_dkdb; run;

*MERGE POPULATION TO DKDB;
data dkdb2;
merge refugees (in=a keep=pnr tilladelsesdato) dkdb (in=b);
by pnr;
if a;
if b then dkdb=1; else dkdb=0;
if t_timer_kuho<0 then t_timer_kuho =0;
run;


*KEEP MOTHER TONGUE FROM DKDB;
data dkdb3;
set dkdb2 ;
by pnr;
if first.pnr;
keep pnr  afghan--wolof;
run;


*LIST OF LANGUAGE DUMMIES;
%let languages = afghan albanian amharic arabic armenian assyrian azeri berber bosnian bulgarian dari english estonian farsi filipino 
finnish french greek greenlandic hebraic hindu dutch indonesian iraqi icelandic italian japanese chinese kirundi korean croatian 
kurdish latvian lithuanian luganda macedonian mandarin mandingo pakistani pashto persian polish portugese punjabi romani romanian 
russian serbian sinhala slovenian slovakian somali spanish swedish tagalog tamil thai tigrinya czech turkish turkmen twi german 
ukrainian hungarian urdu vietnamese wolof;


*MERGE MOTHER TONGUE FROM DKDB TO POPULATION;
data refugees;
merge	refugees (in=a)  dkdb3 ;
by pnr;
if a;
if dkdb=. then dkdb=0;
label dkdb = "In DKDB";

%macro missing(var=);
if &var.=. then &var.=0;
%mend;
%macro t;
%local i next;
%do i=1 %to %sysfunc(countw(&languages));
%let next = %scan(&languages, &i);
%missing(var=&next);
%end;
%mend;
%t;
;
run;

proc sort data=refugees; by pnr; run; 



*SUM HOURS ASSIGNED FOR CLASSES STARTED WITHIN WITH 12-36 MONTHS SINCE ADMISSION;
%macro months;
%do m=12 %to 36 %by 6;
proc means data=dkdb2 (where=(intck('month',tilladelsesdato,start_dato,'C') le &m.)) noprint;
var t_timer_kuho ; by pnr;
output out= _hours_dkdb_month&m. (drop = _type_ _freq_) sum(t_timer_kuho)=hours_assigned_&m.;
run;
%end;
%mend;
%months;



*MERGE LANGUAGE TRAINING TO POPULATION;
data refugees;
merge refugees (in=a) _hours_dkdb_month12 _hours_dkdb_month18 _hours_dkdb_month24 _hours_dkdb_month30 _hours_dkdb_month36;
by pnr;
if a;
%macro months2;
%do m=12 %to 36 %by 6;
if hours_assigned_&m.>0 then in_dkdb_&m.=1; else in_dkdb_&m.=0;
if hours_assigned_&m.=. then hours_assigned_&m.=0;
label hours_assigned_&m.="Hours assigned language training within &m. months of admission" 
in_dkdb_&m.="Ever participating in language training within &m. months of admission";
%end;
%mend;
%months2;
run;




proc sort data=refugees; by pnr; run;


*CREATE UNBALANCED PANEL;
data refugees2 (drop=_kom);
merge persons2 (in=a rename=kom=_kom where=(year_p>=1997)) refugees (in=b) crimes;
by pnr;
if b;
kom=_kom*1;
*SET CRIMES TO MISSING IF INDIVIDUAL HAS NOT ARRIVED YET;
if year(tilladelsesdato) ge 2000 then do;
convicted1=.;
charged1=.;
property_sm_kraf1=.;
property_sm_krsi1=.;
end;
run;





*********************************************************************************************;
*		MERGE ALMP AND EDUCATION INFORMATION TO PANEL OF REFUGEES 					 		*;
*********************************************************************************************;

data refugees3 (drop= hf_kilde: hfaudd: h1-h18 hours_intser:);
merge refugees2 (in=a)
udda1-udda18
almp_intser_12f almp_emplser_12f
almp_intser_18f almp_emplser_18f
almp_intser_24f almp_emplser_24f
almp_intser_30f almp_emplser_30f
almp_intser_36f almp_emplser_36f
;
by pnr;
if a;

%macro m(var=);
if &var.=. then &var.=0;
%mend;
%m(var=dispon_13);
%m(var=UA_sum);


*LABELS;
%macro label(mm=);
label	
		intser_&mm._d="Dummy for integration services (first &mm. months)"
		emplser_&mm._d="Dummy for employment services (first &mm. months)"
;
		%mend;
		%label(mm=12);
		%label(mm=18);
		%label(mm=24);
		%label(mm=30);
		%label(mm=36);

*IF PERSON IS IN AMFORA DATABASE THEN SET MISSING HOURS IN ALMP TO ZERO;
%macro time(t=);
%macro hours(var=);
if hours_&var.&t.=. and (intser&t._d=1 or emplser&t._d=1) then hours_&var.&t.=0;
%mend;
%hours(var=intser);
%hours(var=emplser);
%mend;
%time(t=_12);
%time(t=_18);
%time(t=_24);
%time(t=_30);
%time(t=_36);

*EDUCATION OBTAINED IN DENMARK;
%macro dummy(k=);
udda_dk&k.=0;
if hf_kilde&k. in &educ_dk then udda_dk&k.=1;
label udda_dk&k.="Formal Education in Denmark After &k. Years";
%mend;
%dummy(k=1); %dummy(k=2); %dummy(k=3); %dummy(k=4); %dummy(k=5); %dummy(k=6); %dummy(k=7); %dummy(k=8); %dummy(k=9); %dummy(k=10); %dummy(k=11); 
%dummy(k=12); %dummy(k=13); %dummy(k=14); %dummy(k=15); %dummy(k=16); %dummy(k=17); %dummy(k=18);


*GENERATE DUMMIES FOR EMPLOYED IN COMPLEX JOB AND NON-COMPLEX JOB ANNUALLY;
complex_job=0;
non_complex_job=0;
if int(isco4d/1000) >=1 & int(isco4d/1000) <=5 /*& employment_nov=1*/ then complex_job=1;
if (isco4d ne . | employment_nov=1) & complex_job=0 then non_complex_job=1;
label complex_job= "Employed in Complex Job" 
non_complex_job="Employed in Non-Complex Job";
drop employment_nov;
run;





*********************************************************************************;
*	DATASET WITH CUMULATED OUTCOMES 1 TO 18 YEARS AFTER 1998 (1999-2016)		*;
*********************************************************************************;

%macro cumulate(cumulate=);
data _outcome_&cumulate.;
set refugees3;
if year_p<=1998+%eval(&cumulate.) and year>=year_admission;
rename
emp=employment_&cumulate.
loenmv_13=loenmv_13_&cumulate.
;

run;

proc means data=_outcome_&cumulate. noprint;
var employment_&cumulate. loenmv_13_&cumulate.;
by pnr;
output out=cumulated&cumulate. (drop=_type_ _freq_) sum=/autoname;
run;

proc datasets nolist; delete _outcome:; run;
%mend;
%cumulate(cumulate=1);
%cumulate(cumulate=2);
%cumulate(cumulate=3);
%cumulate(cumulate=4);
%cumulate(cumulate=5);
%cumulate(cumulate=6);
%cumulate(cumulate=7);
%cumulate(cumulate=8);
%cumulate(cumulate=9);
%cumulate(cumulate=10);
%cumulate(cumulate=11);
%cumulate(cumulate=12);
%cumulate(cumulate=13);
%cumulate(cumulate=14);
%cumulate(cumulate=15);
%cumulate(cumulate=16);
%cumulate(cumulate=17);
%cumulate(cumulate=18);





*******************************************************************************************;
*				DATASET WITH ANNUAL OUTCOMES 1-18 YEARS AFTER 1998 (1999-2016)		   	  *;
*******************************************************************************************;

%macro out(years_after=);
data outcome&years_after.;
set refugees3
(keep=pnr year year_p emp UA_sum loenmv_13  
kom dispon_13 isco4d complex_job non_complex_job);
rename
emp=annual_employment_&years_after.
UA_sum=annual_UA_&years_after.
loenmv_13=loenmv_13_&years_after.
kom=kom_%eval(&years_after.-1)
dispon_13=dispon_13_&years_after.
isco4d=isco4d_&years_after.
complex_job=complex_job_&years_after.
non_complex_job=non_complex_job_&years_after.
;
if year_p=1998+%eval(&years_after.);
drop year year_p;
run;
%mend;
%out(years_after=1);
%out(years_after=2);
%out(years_after=3);
%out(years_after=4);
%out(years_after=5);
%out(years_after=6);
%out(years_after=7);
%out(years_after=8);
%out(years_after=9);
%out(years_after=10);
%out(years_after=11);
%out(years_after=12);
%out(years_after=13);
%out(years_after=14);
%out(years_after=15);
%out(years_after=16);
%out(years_after=17);
%out(years_after=18);
%out(years_after=19); *MUNICIPALITY IS MEASURED PRIMO, SO USE THE FOLLOWING YEAR FOR MEASURING MOBILITY FROM INITIAL PLACEMENT*Note municipality is measured primo, so use the following year for mobility;




*********************************************************;
*		CREATE DATASET WITH OUTCOMES AND CONTROLS		*;
*********************************************************;


data population 
(drop= kom_0 loenmv_13_1_sum--loenmv_13_18_sum employment_1_sum--employment_18_sum year_p--foed_dag dispon_13_3-dispon_13_18 durat year imputeret );
merge refugees3 (in=a drop=isco4d emp exper loenmv_13 ua_sum dispon_13 complex_job non_complex_job kom ref1 municipality_org navn application year_application)
outcome1-outcome18 outcome19 (keep=pnr kom_18) cumulated1-cumulated18
;
by pnr;
if a;
if year_p=year+1 and imputeret ne 1 and year_admission < 2001;

*LABELS;
%macro label;
%do years_after=1 %to 18 %by 1;
label
annual_employment_&YEARS_AFTER.		="Annual employment rate &years_after. years after immigration"
annual_UA_&YEARS_AFTER.				="Annual welfare benefits &years_after. years after immigration"
loenmv_13_&years_after.				="Yearly earnings &years_after. years after immigration" 
dispon_13_&years_after.				="Disposable income &years_after. years after immigration"
isco4d_&years_after.				="Four-digit ISCO88 code &years_after. years after immigration, conditional on employment"
complex_job_&years_after.			="In complex job &years_after. years after immigration"
non_complex_job_&years_after.		="In non-complex job &years_after. years after immigration"
kom_&years_after.					="Municipality of residence &years_after. years after immigration"
convicted&years_after.				="Convicted of a Crime &years_after. years after immigration"
;
%end;
%mend;
%label;

label civst ="Marital Status" property_sm_kraf1="Convicted of Shoplifting Year 1" property_sm_kraf2="Convicted of Shoplifting Year 2"
property_sm_krsi1="Charged with Shoplifting Year 1" property_sm_krsi2="Charged with Shoplifting Year 2" charged1="Charged with Crime Year 1"
charged2="Charged with Crime Year 2" opr_land="Origin Country";

*SET MISSINGS TO ZERO AND CREATE LABELS;
%macro vv(var=);
%macro cc;
%do c=1 %to 18 %by 1;
label &var._&c._sum="Cumulated &var. &c. years"; 
if &var._&c._sum=. then do;
&var._&c._sum=0;
end;
%end;
%mend;
%cc;
%mend;
%vv(var=employment);
%vv(var=loenmv_13);

*DUMMY FOR OUTMIGRATION;
if durat=. then outmig=0; else outmig=1;
label outmig ="Outmigration";


*SET MISSINGS TO ZERO;
%macro nov(var=);
%macro aa;
%do i=1 %to 18 %by 1;
if &var._&i. = . then do;
&var._&i. = 0;
end;
%end;
%mend;
%aa;
%mend;
%nov(var=loenmv_13);
%nov(var=annual_employment);
%nov(var=annual_UA);
%nov(var=dispon_13);
%nov(var=complex_job);
%nov(var=non_complex_job);


*SET TO MISSING IF INDIVIDUAL HAS NOT ARRIVED YET;
%macro mis(var=);
if year_admission>=2001 then do;
&var._2=.;
end;
if year_admission>=2000 then do;
&var._1=.;
end;
%mend;
%mis(var=loenmv_13);
%mis(var=annual_employment);
%mis(var=annual_UA);
%mis(var=dispon_13);
%mis(var=complex_job);
%mis(var=non_complex_job);

if level_first=5 then level_first=.;


*AVERAGE CUMULATIVE OUTCOMES;
%macro variable(var=);
%macro year;
%do i=1 %to 18; 
&var._y_&i._sum=&var._&i._sum/&i.;
%end;
%mend;
%year;
%mend;
%variable(var=employment);
%variable(var=loenmv_13);

%macro label2;
%do i=1 %to 18 %by 1;
label	loenmv_13_y_&i._sum="Average Cumulative Earnings in Year &i."
		employment_y_&i._sum="Average Cumulative Employment in Year &i.";
%end;
%mend;
%label2;
run;


proc sort data=population; by pnr; run;



*-----------------------------------------------------------------------------------------------------------;
*	4) EXPORT DATA SETS TO STATA;
*-----------------------------------------------------------------------------------------------------------;



*****************************************************************************************;
*		EXPORT DATASET FOR MAIN ANALYSIS												*;
*****************************************************************************************;

proc export data=population dbms=dta outfile="&input.\Population" replace; run;



*****************************************************************************************;
*		EXPORT DATASET TO STUDY POPULATION BY ADMISSION MONTHS (INCL. JAN-FEB 2001)		*;
*****************************************************************************************;

data population_jan_feb2001;
set refugees3;
if (year_p=year+1) and imputeret ne 1 and tilladelsesdato < '2mar2001'd ;
keep pnr tilladelsesdato opr_land age;
run;

proc sort data=population_jan_feb2001; by pnr; run;

proc export data=population_jan_feb2001 dbms=dta outfile="&input.\Population_jan_feb2001" replace; run;


**********************************************************************************************************************;
*		EXPORT DATASET TO STUDY POPULATION NOT RESTRICTED BY PERMIT DATES - FOR SUBTRACTING SEASONALITY IN ADMISSION *;
**********************************************************************************************************************;

data population_full;
set refugees3;
if (year_p=year+1) and imputeret ne 1;
keep pnr tilladelsesdato opr_land age year_admission;
run;

proc sort data=population_full; by pnr; run;


proc export data=population_full dbms=dta outfile="&input.\Population_full" replace; run;




